【发布时间】:2017-07-08 22:39:29
【问题描述】:
我正在使用 vuejs 路由器构建单页应用程序。 路由器运行良好,但我想在路由到组件后加载特定脚本。
喜欢:
const Mine = {
template: ' <div>Another</div>',
load_script: <script src="/static/script.js"></script>
}
我怎样才能做到这一点?
现在我在 html 中有当前块:
<div id="routing">
<router-view></router-view>
</div>
这是在 js 中:
const Mine = {template: ' <div>Another</div>'}
const routes = [
{ path: '/mine', component: Mine },
]
const router = new VueRouter({
routes,
})
const app = new Vue({
router
}).$mount('#routing')
【问题讨论】:
标签: javascript vue-component vue-router