問題描述我在index.html是這樣寫的:<html><body>
<div id="app">
<sidenav>...</sidenav>
<navbar>...</navbar>
</div><script src="main.js"/></body></html>main.js:const app = new Vue({
el: "#app",
data: {...}, method: {...}});在main.js中的vue app里面定義了navbar和sidenav的一些data和method,我想在其他頁面都能使用這個配置。比如在profile.html中:<html><body>
<div id="app">
<sidenav>...</sidenav>
<navbar>...</navbar>
{{ content... }}
</div><script src="profile.js"/></body></html>我希望在profile中能使用main.js中的app,但同時在profile又會有自己的vue配置,比如:profile.js:const profile = new Vue({
el: "#app",
data: {...}, method: {...}});有什么辦法可以將兩個配置合并呢自己嘗試過的方法我剛開始將navbar和sidenav寫成了單文件組件,但這樣在其他頁面中就不能使用其中的data和methods了
vue.js如何合并多個配置?
慕妹3146593
2018-07-11 12:10:17