1、ElementUi3框架npm i element3 -S引入框架--main.jsimport element3/lib/theme-chalk/index.cssimport { createApp } from vueimport Element3 from element3import App from ./App.vuecreateApp(App).use(Ele...
1、ElementUi3框架
npm i element3 -S
引入框架
--main.js import 'element3/lib/theme-chalk/index.css' import { createApp } from 'vue' import Element3 from 'element3' import App from './App.vue' createApp(App).use(Element3).mount('#app')
2、路由
npm install vue-router
建立页面文件:新建目录views/home.vue,views/test.vue,分别在里面放些显示代码
建立路由文件:新建目录router/index.js
import { createRouter, createWebHashHistory } from "vue-router"; import test1 from '@/views/test1.vue' import home from '@/views/home' const router = new createRouter({ history: createWebHashHistory(process.env.BASE_URL), routes: [ { path: "/", name: 'home', component: home }, { path: '/test', name: 'test', component: test1 } ] })
export default router
修改main.js文件,加入路由
import 'element3/lib/theme-chalk/index.css' import { createApp } from 'vue' import Element3 from 'element3' import router from './router/index' import App from './App.vue' createApp(App).use(Element3).use(router).mount('#app')
修改APP.vue文件
<template> <div id="app"> <router-link to="/">Home</router-link> | <router-link to="/test">About</router-link> </div> <router-view /> </template> <script> export default { name: "App", }; </script>
沃梦达教程
本文标题为:【VUE3.0体验】建路由,加入ElementUI3框架
猜你喜欢
- JS实现左侧菜单工具栏 2022-08-31
- 深入浅析AjaxFileUpload实现单个文件的 Ajax 文件上传库 2022-12-15
- javascript 判断当前浏览器版本并判断ie版本 2023-08-08
- 1 Vue - 简介 2023-10-08
- jsPlumb+vue创建字段映射关系 2023-10-08
- 基于CORS实现WebApi Ajax 跨域请求解决方法 2023-02-14
- ajax实现输入提示效果 2023-02-14
- 关于 html:如何从 css 表中删除边距和填充 2022-09-21
- layui数据表格以及传数据方式 2022-12-13
- vue keep-alive 2023-10-08