This commit is contained in:
zhanghongmin
2022-03-08 14:23:59 +08:00
commit d985fd26f8
18 changed files with 19870 additions and 0 deletions

57
src/App.vue Normal file
View File

@@ -0,0 +1,57 @@
// .vue 文件 vue 的组件
// html css js
//
// 组件
//
<template>
<div class="aaaa">
<router-view></router-view>
<!-- 监听子组件的事件 -->
</div>
</template>
<script>
// 导出
// new Vue
// 组件
// data:{
// name:"这是name"
// }
export default {
name: 'App',
// 注册组件
components:{
},
methods: {
dianwo() {
// alert("事件")
this.name = "这是新的sname"
},
aaa(canshu,canshuer,canshusan){
console.log("子组件被点击了")
console.log("传过来的值是",canshu)
console.log("传过来的值2是",canshuer)
console.log("传过来的值3是",canshusan)
},
zijideshijian(xingcan,xingcan2){
console.log("事件被触发了")
console.log(xingcan)
console.log(xingcan2)
}
},
data() {
return {
name: "这是name",
jiage:0
}
}
}
</script>
<style>
</style>

BIN
src/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -0,0 +1,59 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
这是hello world
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
// 组件的名子
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
// 后面会有影响
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

14
src/components/aaa.vue Normal file
View File

@@ -0,0 +1,14 @@
<template>
<div>
<div>这是aaaa</div>
</div>
</template>
<script>
export default {
name:"AaaCom"
}
</script>

69
src/components/luyou.vue Normal file
View File

@@ -0,0 +1,69 @@
<template>
<div style="display: flex;">
<el-row class="tac" style="width:30%">
<el-col :span="12">
<h5>自定义颜色</h5>
<el-menu
default-active="2"
class="el-menu-vertical-demo"
@open="handleOpen"
@close="handleClose"
background-color="#545c64"
text-color="#fff"
active-text-color="#ffd04b">
<el-submenu index="1">
<template slot="title">
<i class="el-icon-location"></i>
<span>导航一</span>
</template>
<el-menu-item-group>
<template slot="title">分组一</template>
<el-menu-item index="1-1" @click="$router.push('/login/abc')">选项1</el-menu-item>
<el-menu-item index="1-2" @click="$router.push('/login/user')">选项2</el-menu-item>
</el-menu-item-group>
<el-menu-item-group title="分组2">
<el-menu-item index="1-3">选项3</el-menu-item>
</el-menu-item-group>
<el-submenu index="1-4">
<template slot="title">选项4</template>
<el-menu-item index="1-4-1">选项1</el-menu-item>
</el-submenu>
</el-submenu>
<el-menu-item index="2">
<i class="el-icon-menu"></i>
<span slot="title">导航二</span>
</el-menu-item>
<el-menu-item index="3" disabled>
<i class="el-icon-document"></i>
<span slot="title">导航三</span>
</el-menu-item>
<el-menu-item index="4">
<i class="el-icon-setting"></i>
<span slot="title">导航四</span>
</el-menu-item>
</el-menu>
</el-col>
</el-row>
<div>
<router-view></router-view>
</div>
</div>
</template>
<script>
export default {
name: "luiYou",
methods: {
handleClose(key, keyPath) {
console.log(key, keyPath);
},
toindex(){
},
},
};
</script>
<style scoped>
</style>

40
src/components/zujian.vue Normal file
View File

@@ -0,0 +1,40 @@
<template>
<div>
商品
计数: {{count}}
<button @click="dianwo">点我</button>
<button @click="jian"></button>
</div>
</template>
<script>
export default {
name:"ZuJian",
data(){
return {
count:0
}
},
methods:{
dianwo(){
// console.log("事件触发")
this.count++
// vue 自带的
// 父传子 属性
// 子传父 事件
// 触发 父级的事件
this.$emit("abc",this.count,"第二个参数")
// 子传父
// this.$emit("aaa",2222,1111,6666)
},
jian(){
this.count--
// this.$emit("aaa",this.count)
}
}
}
</script>
<style>
</style>

49
src/main.js Normal file
View File

@@ -0,0 +1,49 @@
// js 导入 模块式开发
import Vue from 'vue'
// 导入 App.vue
import App from './App.vue'
// import zujian from "./components/zujian.vue"
import HelloWorld from "./components/HelloWorld.vue"
import aaa from "./components/aaa.vue"
import VueRouter from "vue-router"
import index from "./pages/index.vue"
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
// vuerouter 插件
Vue.use(ElementUI);
Vue.use(VueRouter)
// 路径 => 页面(组件)
const routes = [{
path:"/abc",
component:HelloWorld
},{
path:"/agfahg",
component:aaa
}, {
path:"/",
component: index
}, {
path:"/login",
component:() =>import("./components/luyou.vue"),
children:[{
path:"user",
component: () => import("./pages/user.vue")
},{
path:"abc",
component:HelloWorld
}]
}]
const router = new VueRouter({
routes // (缩写) 相当于 routes: routes
})
Vue.config.productionTip = false
new Vue({
render: h => h(App),
router
}).$mount('#aaa')

72
src/pages/index.vue Normal file
View File

@@ -0,0 +1,72 @@
<template>
<div>
这是首页
<!-- <a href="/#/user">到user</a> -->
<!-- vue router 跳转页面 用router-link -->
<!-- 声明式导航 -->
用户名:<input v-model="user" type="text" name="" id="">
<router-link to="/user">到user</router-link>
<!-- 编程式导航 -->
<!-- js 跳转 -->
<!-- 事件 -->
<button @click="touser">点我跳转到user</button>
<button @click="back">返回上一页</button>
<button @click="next">去下一页</button>
<button @click="list.reverse()">反转数组</button>
<ul class="app">
<li v-for="(item,index) in list" :key="index"><span>{{item.name}}</span><input type="text" name="" id=""></li>
</ul>
</div>
</template>
<script>
export default {
name:"PageIndex",
data(){
return {
user:"",
list:[{
name:"小白",age:16
},{
name:"小明",age:18
},]
}
},
methods:{
chuancan(index){
this.$router.push({
path:"user",
query:{
canshuming:this.list[index]
}
})
},
touser(){
//
// location.href = "/user"
// vuerouter
// this.$router.push("/user?user=" + this.user)
this.$router.push({
path:"/user",
query:{
canshuming:this.user,
canshuer:123456
}
})
// 传参
// this.$router.push({path:"/user"})
// this.$router.replace("/user")
},
back(){
// 前进 后退
this.$router.go(-1)
},
next(){
this.$router.go(1)
}
}
}
</script>
<style>
</style>

30
src/pages/user.vue Normal file
View File

@@ -0,0 +1,30 @@
<template>
<div>这是user
<button @click="back" class="app">返回上一页</button>
<button @click="next">去下一页</button>
<button @click="getquery" >获取传参</button>
</div>
</template>
<script>
export default {
name:"PageUser",
methods:{
back(){
this.$router.go(-4)
},
next(){
this.$router.go(1)
},
getquery(){
console.log(this.$route.query.canshuming)
}
}
}
</script>
<style scoped>
.app{
background-color: aqua;
}
</style>