Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

样式注入到html文档时顺序发生错乱(Dialog样式在Button样式之前) #1758

Closed
chuckyo opened this issue Sep 5, 2018 · 1 comment

Comments

@chuckyo
Copy link

chuckyo commented Sep 5, 2018

vant版本:1.2.1
nuxt版本:1.4.2

哈喽,参考 #782@PepperYan 的方法使用nuxt+vant构建的SSR项目

// nuxt.config.js
build {
  babel: {
    plugins: [
      [
        'component',
        {
          libraryName: 'vant',
          styleLibraryName: 'vant-css',
          style: true
        }
      ]
    ]
  }
}
// plugins/vant.js
import Vue from 'vue'
import { Button, Dialog } from 'vant'

// Button与Dialog执行的顺序并不会影响其样式注入到html文档的顺序
// 其它组件的样式会根据下面代码的顺序发生改变
// 比如若增加组件Loading,若先执行Vue.use(Loading)后执行Vue.use(Button),
// 则Loading组件样式的style标签将位于Button组件样式的style标签下方
Vue.use(Button)
Vue.use(Dialog)

产生的结果:
image

由于dialog组件样式被button组件覆盖,所以UI并未按预期表现:
image

尝试过yarn build之后再执行yarn start也是相同的结果。

提前感谢:)

@chenjiahan
Copy link
Member

建议去 babel-plugin-component 仓库下提问

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants