Vue中使用组件
2017-08-02 12:04
218 查看
Vue使用组件分为三步:
1、在html中使用要自定义的组件,比如<div id="example"> <my-component></my-component> </div>
2、将该组件进行注册
Vue.component('my-component', { template: '<div>A custom component!</div>' })
3、创建根实例
new Vue({ el: '#example' })
最终的渲染结果就变成了
<div id="example"> <div>A custom component!</div> </div>
局部注册方式
var Child = { template: '<div>A custom component!</div>' } new Vue({ // ... components: { // <my-component> 将只在父模板可用 'my-component': Child } })
相关文章推荐
- Vue.js-----轻量高效的MVVM框架(八、使用组件)
- VUE 使用新版本 element-ui 组件库 Select 组件时, value 值为对象时的 BUG 处理
- 使用Vue开发网站之路2-多组件通信1(利用bus总线进行事件触发)
- 怎么直接中vue组件的style使用less,不是引入less
- Vue 组件和插槽的理解与使用
- Vue 子组件无法使用 $emit 向父组件传参
- vue.js基本使用 父子组件<三>
- Vue.js使用-组件示例(实现数据的CRUD)
- webpack+vue-loader 在单独.vue组件中使用sass-loader编译sass报错问题not a valid Win32 applictation
- vue项目优化之按需加载组件-使用webpack require.ensure
- Vue.js入门学习--组件的注册使用+开奖小游戏(八)
- vue组件详解(四)——使用slot分发内容
- 使用vue配合组件--转载
- vue2.3.0+使用.sync修饰符对prop进行双向绑定/子组件同步prop到父组件绑定的值
- vue项目中使用地图组件
- vue.js使用props在父子组件之间传参
- vue2.0 使用element-ui里的upload组件实现图片预览效果方法
- vue-cli项目中使用公用的提示弹层tips或加载loading组件实例详解
- vue-cli 组件的使用
- vue组件vue-rounter,router-link标签使用