Session

Vue 组件操作

电脑版发表于:2021/5/19 11:00

前言

Vue组件,类似于mvc里的分布页

可以重用Vue的实例,相当于是自定义一个控键,


template:模板

methods: 方法

slot:插槽

定义一个Vue组件

 <div id="content">

    <组件名>插槽数据</组件名>
  </div>
 
 
 
 //创建一个组件
 Vue.component("组件名", {
          data: function () {
          
                return {
                    count: 1
                }
            },
         }),
         template:"<div><slot></slot><button v-on:click='run'>你点击了{{count}}次</button></div>",
         methods: {
               run: function () {
               this.count++
               }
        }


关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢