diff --git a/src/_mixins/usecssr.js b/src/_mixins/usecssr.js index e6bbfdf50..e4f67353c 100644 --- a/src/_mixins/usecssr.js +++ b/src/_mixins/usecssr.js @@ -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() diff --git a/src/_styles/index.js b/src/_styles/index.js new file mode 100644 index 000000000..1617885f5 --- /dev/null +++ b/src/_styles/index.js @@ -0,0 +1,3 @@ +export { + default as globalStyle +} from './global/index.cssr.js' diff --git a/src/create.js b/src/create.js index cef2b122c..33d09359a 100644 --- a/src/create.js +++ b/src/create.js @@ -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 => { diff --git a/vue3.md b/vue3.md index 23b4b02cf..b827e91ce 100644 --- a/vue3.md +++ b/vue3.md @@ -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