6
私はVue Cliとwebpackを使って、背中用のNodeJS/ExpressとFront用のVueJSでアプリケーションを作成しています。VueルータWebpackドットでParams
私のルートのパラメータをドットで許可する方法があるかどうかを知りたいのですが。ここで
は私がいない設定ここCannot GET /t/firstname.lastname
にしようとすると、私も私、私の/src/main.js
import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource'
import VueAutosize from 'vue-autosize'
import Main from './components/Main.vue'
import Signin from './components/Signin.vue'
// We want to apply VueResource and VueRouter
// to our Vue instance
Vue.use(VueRouter)
Vue.use(VueResource)
Vue.use(VueAutosize)
const router = new VueRouter({
history: true
})
// Pointing routes to the components they should use
router.map({
'/t/:person': {
component: Main
},
'/signin': {
component: Signin
}
})
router.beforeEach(function (transition) {
if (transition.to.path === '/signin' && window.localStorage.length !== 0) {
transition.redirect('/')
} else if (transition.to.path === '/' && window.localStorage.length === 0) {
transition.redirect('/signin')
} else {
transition.next()
}
})
// Any invalid route will redirect to home
router.redirect({
'*': '/404'
})
router.start(App, '#app')
私はvue-routerがurlのparamをjavascriptオブジェクトに変換するので、ポイントの使用は許可されていないと思います。しかし、私は他の句読点でテストしましたが、大丈夫です。 必要に応じてregexpまたはoptionnalパラメータを使用できます。> [https://github.com/vuejs/vue-router/blob/9649929b3646954c7b59d149c570c3d0a96379c9/examples/route-matching/app.js](https://github.com/) vuejs/vue-router/blob/9649929b3646954c7b59d149c570c3d0a96379c9/examples/route-matching/app.js) –
@utiiz解決策を見つけましたか?私は同じ問題を抱えています。 –
これはWebpackとどのように関連していますか? –