From 22c89e6b2ef66d0a803372232683184bbda916f2 Mon Sep 17 00:00:00 2001 From: adb Date: Wed, 10 Mar 2021 01:49:29 +0100 Subject: [PATCH] move vue router --- src/main.js | 85 ++++++++++------------------------------------------- 1 file changed, 15 insertions(+), 70 deletions(-) diff --git a/src/main.js b/src/main.js index 78d29e5..7ae9ae9 100644 --- a/src/main.js +++ b/src/main.js @@ -1,81 +1,26 @@ -import Vue from "vue" -import VueRouter from "vue-router" -import App from "./App.vue" -import login from "./views/login.vue" -import chat from "./views/chat.vue" -import rooms from "./views/rooms.vue" +import Vue from 'vue' +import VueRouter from 'vue-router' +import App from './App.vue' +import {router} from './router.js' Vue.config.productionTip = false 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 { - data(){ - return { - chatroom: chatroom - } - }, - methods: { - error(msg){ - show_error(msg) - }, - router(route){router.push(route)} - } + methods: { + router(route){router.push(route)} + } } new Vue({ - el: "#app", - router, - template: "", - components: {App}, - data(){ - return { - chatroom: chatroom - } + el: '#app', + router, + template: '', + components: {App}, + data(){ + return { } -}).$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) -} \ No newline at end of file + } +}).$mount('#app')