摘要: 场景: new Vue({ el: '#app', render: h => h(App) }) 初始化渲染时在根实例的mountComponent方法中new Watcher() 在实例化watcher的过程中会调用updateComponent回调方法,这是会调用render函数,在执行rend 阅读全文
posted @ 2021-02-23 10:43 ltog 阅读(200) 评论(0) 推荐(0)
摘要: Vue.component('HelloWorld', function(resolve, reject) { require(['./components/HelloWorld'], function(res) { resolve(res); }) }) 对于这个异步组件例子都完整加载流程 先执行 阅读全文
posted @ 2021-02-20 10:32 ltog 阅读(82) 评论(0) 推荐(0)
摘要: new Vue发生了什么 此处只针对最简单基础的new Vue过程,一般项目中采用.vue单文件组件的形式开发,下面会介绍 对于 runtime+compile 版本: 初始化一个 vue 实例的一系列相关环境(watcher,lifecycle, methods等等), compile:将 tem 阅读全文
posted @ 2021-02-02 17:43 ltog 阅读(114) 评论(0) 推荐(0)
摘要: <script> export default { data () { return { item: ['张三','李四','小明'] } }, // 在组件中使用,去除组件中的template标签 (组件中的template标签中的内容编译时最终都会编译成render函数) // createEl 阅读全文
posted @ 2021-01-26 18:23 ltog 阅读(327) 评论(0) 推荐(0)
摘要: 官方文档:https://cn.vuejs.org/v2/api/#Vue-extend vue.extend使用基础 Vue 构造器,创建一个“子类”。参数是一个包含组件选项的对象。 extend是产生一个继承自Vue类的子类,只会影响这个子类的实例对象,不会对Vue类本身以及Vue类的实例对象产 阅读全文
posted @ 2021-01-26 18:03 ltog 阅读(168) 评论(0) 推荐(0)
摘要: 组件渲染过程 template --> ast --> render --> 虚拟Dom--> 真实的Dom --> 页面 runtime-only 我们在使用 runtime-only 的时候,需要借助 webpack的loader工具,将 .vue 文件编译为JavaScript,因为是在编译阶 阅读全文
posted @ 2021-01-25 18:12 ltog 阅读(72) 评论(0) 推荐(0)
摘要: 新建一个bus.js文件,并在main.js引入并全局使用它 import Vue from 'vue' const bus = new Vue({ data: { number: 1 } }) export default { install() { Object.defineProperty(V 阅读全文
posted @ 2021-01-20 15:26 ltog 阅读(1707) 评论(0) 推荐(0)
摘要: 创建一个message.vue组件 <template> <transition name="message-transition"> <div v-show="show" class="message"> <div class="message-content">{{ content }}</di 阅读全文
posted @ 2021-01-20 15:09 ltog 阅读(2182) 评论(0) 推荐(0)
摘要: /* 固定用法, 多行溢出显示省略号,最好不要设置height,让height自适应 */ .div { overflow: hidden; text-overflow: ellipsis; white-space: normal !important; display: -webkit-box; 阅读全文
posted @ 2021-01-15 14:16 ltog 阅读(62) 评论(0) 推荐(0)
摘要: function getRandomInt(min,max) { return Math.floor(Math.random() * (max - min + 1) + min) // return Math.floor(Math.random() * (max + 1)) } // 洗牌函数(数组 阅读全文
posted @ 2021-01-05 10:39 ltog 阅读(398) 评论(0) 推荐(0)