I'm trying to get Vue.js with the vue-router working. In my example I'd like to add a subroute/nested route to a view/template, but I get an "invalid expresion" error.
Here is the jsFiddle example: http://jsfiddle.net/diemah77/18t6xkku/11/
app.html:
<div id="app">
<h1>Hello App!</h1>
<p>
<a v-link="{ path: '/foo' }">Go to /foo</a>
<a v-link="{ path: '/bar' }">Go to /bar</a>
</p>
<router-view></router-view>
</div>
app.js:
var Foo = Vue.extend({
template:
'<div class="foo">' +
'<h2>This is Foo!</h2>' +
'<router-view></router-view>' + // <- nested outlet
'</div>'
})
var Bar = Vue.extend({
template:
'<p>This is bar!</p>' +
'<ul>' +
'<li><a v-link="{ path: "/profile"}"</a></li>' +
'<ul>' +
'<router-view></router-view>'
})
var Profile = Vue.extend({
template: '<p>This is profile!</p>'
})
// configure router
var router = new VueRouter()
router.map({
'/foo': {
component: Foo,
},
'/bar': {
component: Bar,
subRoutes: {
'/profile': {
component: Profile
}
}
}
})
// start app
var App = Vue.extend({})
router.start(App, '#app')
The nested link inside the Bar component is the one not working.
Any ideas?
", it's not really necessary to escape the single quotes inside. Just like inv-if="prop == 'value'"inside a tag.