move vue router

update_chat
adb 4 years ago
parent 08338551ad
commit 22c89e6b2e

@ -1,81 +1,26 @@
import Vue from "vue" import Vue from 'vue'
import VueRouter from "vue-router" import VueRouter from 'vue-router'
import App from "./App.vue" import App from './App.vue'
import login from "./views/login.vue" import {router} from './router.js'
import chat from "./views/chat.vue"
import rooms from "./views/rooms.vue"
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(VueRouter) Vue.use(VueRouter)
const router = new VueRouter({
routes: [
{
path: "/",
name: "home",
component: login
},
{
path: "/login",
name: "login",
component: login
},
{
path: "/chat/*",
name: "chat",
component: chat
},
{
path: "/rooms/*",
name: "room",
component: rooms
},
{
path: "/rooms",
name: "rooms",
component: rooms
}
]
})
let chatroom = {
name: "open chat",
user: [],
username: "you",
messages: []
}
export default { export default {
data(){ methods: {
return { router(route){router.push(route)}
chatroom: chatroom }
}
},
methods: {
error(msg){
show_error(msg)
},
router(route){router.push(route)}
}
} }
new Vue({ new Vue({
el: "#app", el: '#app',
router, router,
template: "<App/>", template: '<App/>',
components: {App}, components: {App},
data(){ data(){
return { return {
chatroom: chatroom
}
} }
}).$mount("#app") }
}).$mount('#app')
function element(id){ return document.getElementById(id)}
function show_error(msg) {
let error_style = element("errorBox").style
element("errorMessage").innerText = msg
error_style.display = "block"
error_style.animation = "slide-from-left alternate 0.2s"
setTimeout(() => {error_style.animation = ""}, 200)
}

Loading…
Cancel
Save