十度公司做网站怎么样,绍兴建设网站,江西省建设厅教育网站上查询,网站报价方案怎么做1.一个重要的内置关系#xff1a;VueComponent.prototype.proto Vue.prototype 2.为什么要有这个关系#xff1a;让组件实例对象#xff08;vc#xff09;可以访问到 Vue原型上的属性、方法。
案例证明#xff1a;
!DOCTYPE html
html langenVueComponent.prototype.proto Vue.prototype 2.为什么要有这个关系让组件实例对象vc可以访问到 Vue原型上的属性、方法。
案例证明
!DOCTYPE html
html langen
headmeta charsetUTF-8title一个重要的内置关系/title!-- 引入Vue --script typetext/javascript src../js/vue.js/script
/head
bodydiv idrootschool/school/div
/bodyscriptVue.prototype.x 99; //Vue原型上添加一个属性x//创建school组件const school Vue.extend({name:school,template:divh2学校名称{{schoolName}}/h2h2学校地址{{address}}/h2button clickshowX点我输出x/button/div,data(){return {schoolName:尚硅谷,address:北京昌平}},methods: {showX(){console.log(this.x); //此处就可以拿到Vue身上的x}}});const vm new Vue({el:#root,components:{school}});/script
/html