02. Login & Router & Permissions
一. 搭建登录模块
创建登录的代码文件模块 (
src/views/account/AccountLogin.vue)配置路由
router/index.ts
ts
// Home
{
path: '/',
name: 'home',
redirect: 'Login'
},
// Login
{
path: '/',
name: 'Login',
component: () => import('../views/account/AccountLogin.vue')
}1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
- 写静态页面
Fixed Bug
[ts] must use 'import type'- Error Info :
shThis import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'.1- Bug Fixed : 将
import改为import type
js// AccountLogin.vue import type { ElForm } from 'element-ui/types/form'1
2
3[ts] Property '$refs' does not exist- Error Info :
shProperty '$refs' does not exist on type '{ login(): void; }'.1- Bug Fixed : 在
Vue2.x中使用TypeScript,需要引用vue-property-decorator。 vue-property-decorator 使用
ts// AccountLogin.vue <script lang="ts"> import { Vue, Component } from 'vue-property-decorator' @Component export default class extends Vue { } </script>1
2
3
4
5
6
7
8