new Vue({ render: h => h(App), }).$mount('#app')到底什么意思


export default 打包的发布的时候,template以及style样式会跟着一起打包。

render函数的作用

render函数是vue通过js渲染dom结构的函数createElement,约定可以简写为h

render: h => h(App) 是下面内容的缩写:

render: function (createElement) {
    return createElement(App);
}

继续缩写

render (createElement) {
    return createElement(App);
}

继续缩写

render (h) {
    return h(App);
}

箭头函数

h => h(App);

实际渲染

import App from './App'
new Vue({
    el: '#root',
    template: '<App></App>',
    components: {
        App
    }
})

https://cn.vuejs.org/v2/api/#vm-mount

https://cn.vuejs.org/v2/guide/render-function.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM