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框架
基础教程推荐
猜你喜欢
- uniapp开发微信小程序自定义顶部导航栏功能实例 2022-10-21
- JS滚动到顶部踩坑解决记录 2023-07-10
- Ajax发送和接收请求 2022-12-15
- Ajax+smarty技术实现无刷新分页 2022-12-15
- 关于Ajax跨域问题及解决方案详析 2023-02-23
- 使用ajax跨域调用springboot框架的api传输文件 2023-02-23
- Javascript Bootstrap的网格系统,导航栏和轮播详解 2023-08-11
- cocos creator游戏实现loading加载页面,游戏启动加载动画 2022-10-29
- HTML clearfix清除浮动讲解 2022-11-20
- 在实战中可能碰到的几种ajax请求方法详解 2023-02-01