car_deal_util/code/web/car_dealer/vue/vue_01.html

85 lines
2.6 KiB
HTML
Raw Normal View History

2022-10-20 10:04:19 +00:00
<!--
* @Author: Kane
* @Date: 2022-10-20 15:07:59
* @LastEditors: Kane
2022-10-21 11:03:12 +00:00
* @LastEditTime: 2022-10-21 16:29:39
2022-10-20 10:04:19 +00:00
* @FilePath: \car_dealer\vue\vue_01.html
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
-->
<!DOCTYPE html>
<html lang="en">
2022-10-21 03:49:40 +00:00
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>vue3入门</title>
<link rel="stylesheet" href="../css/root.css" />
<link rel="stylesheet" href="../css/normalize.css" />
<link rel="stylesheet" href="../css/kane.css" />
<script src="../js/vue/vue.global.js"></script>
</head>
2022-10-20 10:04:19 +00:00
2022-10-21 03:49:40 +00:00
<body>
<div id="app">
<div class="content">
<h1>{{title}}</h1>
<h1>{{count}}</h1>
<button type="button" v-on:click="addCount()">计数器</button>
<button type="button" v-on:click="switchButton()">
{{btn_title}}
</button>
<hr />
<h1>测试列表渲染</h1>
2022-10-21 11:03:12 +00:00
<h3>员工数量:{{stuffCount}}</h3>
2022-10-21 03:49:40 +00:00
<table>
2022-10-21 11:03:12 +00:00
<tr v-for="(stuff,index) in stuff_list" v-bind:key="index">
<td>{{index+1}}</td>
2022-10-21 03:49:40 +00:00
<td>{{stuff.name}}</td>
<td>{{stuff.age}}</td>
</tr>
</table>
<hr />
</div>
2022-10-20 10:04:19 +00:00
</div>
2022-10-21 03:49:40 +00:00
</body>
<script>
const app = {
data() {
return {
title: "vue3 入门!",
count: 0,
btn_title: "走你",
btn_switch: true,
stuff_list: [
{ name: "kane1", age: "40" },
{ name: "kane2", age: "41" },
{ name: "kane3", age: "42" },
{ name: "kane4", age: "43" },
{ name: "kane5", age: "44" },
],
};
2022-10-20 10:04:19 +00:00
},
2022-10-21 03:49:40 +00:00
methods: {
addCount() {
this.count++;
},
switchButton() {
this.btn_switch = !this.btn_switch;
this.btn_title = this.btn_switch ? "走你!" : "滚";
},
2022-10-20 17:19:47 +00:00
},
2022-10-21 11:03:12 +00:00
computed: {
stuffCount() {
return this.stuff_list.length;
},
},
2022-10-21 03:49:40 +00:00
};
2022-10-20 10:04:19 +00:00
2022-10-21 03:49:40 +00:00
const vm = Vue.createApp(app);
2022-10-20 10:04:19 +00:00
2022-10-21 03:49:40 +00:00
vm.mount("#app");
</script>
</html>