refactor: mount global style when install

This commit is contained in:
07akioni 2020-11-07 15:13:30 +08:00
parent f36f787668
commit 3f86771a6a
4 changed files with 10 additions and 6 deletions

View File

@ -1,5 +1,4 @@
import { find } from '../_utils/cssr'
import globalStyle from '../_styles/global/index.cssr.js'
import { warn } from '../_utils'
if (__DEV__) {
@ -198,10 +197,6 @@ const usecssr = function (styles = [], cssrPropsOption) {
}
} : undefined,
beforeMount () {
globalStyle.mount({
target: 'naive-ui-global',
count: false
})
styles.forEach(style => {
if (__DEV__) {
window.naive.styleRenderingDuration -= performance.now()

3
src/_styles/index.js Normal file
View File

@ -0,0 +1,3 @@
export {
default as globalStyle
} from './global/index.cssr.js'

View File

@ -1,4 +1,5 @@
import version from './version'
import { globalStyle } from './_styles'
import { warn } from './_utils'
function setHljs (hljs) {
@ -72,6 +73,10 @@ function create (options = {}) {
}
function install (app) {
if (installTargets.includes(app)) return
globalStyle.mount({
target: 'naive-ui-global',
count: false
})
installTargets.push(app)
app.config.globalProperties.$naive = naive
components.forEach(component => {

View File

@ -320,7 +320,8 @@
- [x] log scrollTo 有点问题
- [x] remove hollowoutable
- [ ] styleScheme, css variables 组件
- [ ] use-global-style ? 感觉效果不会特别好而且还是很无谓的性能开销
- [x] use-global-style ? 感觉效果不会特别好而且还是很无谓的性能开销
这个问题可以之后再思考,现阶段 vue 的写法还是全局 install
- [x] dynamic-input, no value
## Info