下载并运行https://github.com/Armour/vue-typescript-admin-template模板项目,熟悉了前端项目的基本结构,了解了vue,vuex,typescript,element-ui怎么结合一块开发项目,并自由添加路由以及页面。
以下是我添加的页面:test组件
<template>
<div>
<el-button type="primary" size="mini" plain="true">
提交
</el-button>
<br>
<el-switch v-model="value" @change="changeSwitch"/>
{{ name }}
<br>
<el-slider v-model="value1" />
<br>
<el-carousel height="300px" type="card">
<el-carousel-item v-for="item in 4" :key="item">
<h3 class="small">
{{ item }}
</h3>
</el-carousel-item>
</el-carousel>
<br>
<div style="width: 500px; height: 300px; overflow: auto">
<el-image v-for="url in urls" :key="url" :src="url" lazy style="width: 100%; height: 300px" fit="scale-down"/>
</div>
<el-backtop :right="100" :bottom="100">
<div style="width: 20px; height: 20px; color: darkred; text-align: center; line-height: 20px;">
top
</div>
</el-backtop>
<div style="height: 1000px; background: pink; width: 200px;" />
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
@Component({
name: 'Test'
})
export default class extends Vue {
private value: boolean = false
private name: string = 'helloword'
private index: number = 0
private value1: number = 20
private changeSwitch() {
this.name = `hello ${this.index++}`
}
private urls: string[] = ['https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg',
'https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg',
'https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg',
'https://fuss10.elemecdn.com/9/bb/e27858e973f5d7d3904835f46abbdjpeg.jpeg',
'https://fuss10.elemecdn.com/d/e6/c4d93a3805b3ce3f323f7974e6f78jpeg.jpeg',
'https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg',
'https://fuss10.elemecdn.com/2/11/6535bcfb26e4c79b48ddde44f4b6fjpeg.jpeg']
}
</script>
<style lang="scss" scoped>
.el-carousel__item h3 {
color: #475669;
font-size: 14px;
opacity: 0.75;
line-height: 150px;
margin: 0;
}
.el-carousel__item:nth-child(2n) {
background-color: #99a9bf;
}
.el-carousel__item:nth-child(2n+1) {
background-color: #d3dce6;
}
</style>