- JS
- vue.component("greeting",{
- template:`
{{name}}: 大家好, 给大家介绍我的女朋友: 关晓彤
v-on:click='changeName'> 改名
- `,
- data:function(){
- return{
- name :"鹿晗"
- }
- },
- methods:{
- changeName:function(){
- this.name = "我";
- }
- }
- })
- new Vue({
- el:"#vue-app-one"
- });
- new Vue({
- el:"#vue-app-two"
- });
- html
- lang="en">
- charset="UTF-8">
- rel="stylesheet" type="text/CSS" href="style.css">
- src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">
- id="vue-app-one">
- id="vue-app-two">
- type="text/javascript" src='app.js'>
我: 大家好, 给大家介绍我的女朋友: 关晓彤 改名
鹿晗: 大家好, 给大家介绍我的女朋友: 关晓彤 改名
来源: http://www.bubuko.com/infodetail-3160235.html