【发布时间】:2019-11-28 16:23:00
【问题描述】:
这是我在 2 个不同的 .chtml 文件中的代码,每个文件都包含 .js 文件。
- Layout.cshtml
- 文件1.cshtml
- vue1.js
- vue2.js
我正在使用c# .net mvc
Layout.cshtml
<div id="vuemainlayoutdiv">
<button v-on:click="onClick1()>
Click 1
</button>
<!--rendering File.html-->
@RenderBody()
</div>
文件1.cshtml
<div id="AppcentralVue">
<button v-on:click="onClick2()>
Click 1
</button>
</div>
vue1.js
new Vue({
el: '#vuemainlayoutdiv',
data: {
name: 'first click',
},
methods: {
onClick1: function(){
alert(this.name);
}
}
});
vue2.js
new Vue({
el: '#AppcentralVue',
data: {
name: 'second click',
},
methods: {
onClick2: function(){
alert(this.name);
}
}
});
我正在尝试从另一个 Vue 访问 Vue,但无法达到我的目标。因此,我请求您的帮助。
【问题讨论】:
标签: c# html vue.js model-view-controller razor