[英]Vuejs - Show pages/Vue files with a different router than vue-router (Backbone router)
我有一个主干路由器,我决定使用 Vuejs 进行渲染,但不知道如何实现。
目前,在每条路由上,我使用 require 方法获取带有<template>
和<script>
的.vue
文件并将其发送到 render 方法,但这看起来和感觉很疯狂,我想知道是否有官方方式或一些资源。
//Backbone router structure
var router = Backbone.Router.extend({
routes: {
"": "home",
"about": "about",
"contact":"contact"
},
home: function(){
bin.log('Mounted Home');
},
about: function(){
bin.log('Mounted About');
},
contact: function(){
bin.log('Mounted Contact');
}
});
var currentRoutePage = require('vues/page' + routeName + '.vue');
new Vue({
el: '#app',
render: function (createElement) {
return createElement(currentRoutePage);
}
});
这是一个你可以玩的垃圾箱: http ://www.webpackbin.com/4yGbxwd8f
在这里找到答案,不幸的是,webpackbin.com 服务有一些问题,我无法在线完成这项工作,但它适用于我的本地设置:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.