commit
This commit is contained in:
@@ -4,10 +4,10 @@
|
|||||||
* @Author: Ruin 🍭
|
* @Author: Ruin 🍭
|
||||||
* @Date: 2022-03-10 10:15:34
|
* @Date: 2022-03-10 10:15:34
|
||||||
* @LastEditors: 刘引
|
* @LastEditors: 刘引
|
||||||
* @LastEditTime: 2022-03-10 10:51:31
|
* @LastEditTime: 2022-03-10 13:25:51
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div class="header-root">我是足部组件</div>
|
<div class="header-root">我是公共足部组件</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4,11 +4,23 @@
|
|||||||
* @Author: Ruin 🍭
|
* @Author: Ruin 🍭
|
||||||
* @Date: 2022-03-10 10:15:28
|
* @Date: 2022-03-10 10:15:28
|
||||||
* @LastEditors: 刘引
|
* @LastEditors: 刘引
|
||||||
* @LastEditTime: 2022-03-10 10:46:16
|
* @LastEditTime: 2022-03-10 14:58:15
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div class="root">我是头部组件</div>
|
<div class="root">我是公共头部组件</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed, onBeforeMount } from 'vue';
|
||||||
|
import { useStore } from 'vuex';
|
||||||
|
const store = useStore()
|
||||||
|
|
||||||
|
|
||||||
|
onBeforeMount(() => {
|
||||||
|
|
||||||
|
})
|
||||||
|
computed(() => {
|
||||||
|
console.log(123);
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
||||||
@@ -4,20 +4,34 @@
|
|||||||
* @Author: Ruin 🍭
|
* @Author: Ruin 🍭
|
||||||
* @Date: 2022-01-25 17:00:37
|
* @Date: 2022-01-25 17:00:37
|
||||||
* @LastEditors: 刘引
|
* @LastEditors: 刘引
|
||||||
* @LastEditTime: 2022-01-25 17:00:38
|
* @LastEditTime: 2022-03-10 15:55:57
|
||||||
*/
|
*/
|
||||||
import { createStore } from "vuex";
|
import { createStore } from "vuex";
|
||||||
export default createStore({
|
export default createStore({
|
||||||
|
// 存放数据
|
||||||
state: {
|
state: {
|
||||||
userInfo: {
|
userInfo: {
|
||||||
name: "yk",
|
name: "testVueX",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// 同步方法更改state中属性的状态
|
||||||
mutations: {
|
mutations: {
|
||||||
getUserInfo(state, name) {
|
getUserInfo(state, name) {
|
||||||
state.userInfo.name = name;
|
state.userInfo.name = "我的值被改动";
|
||||||
|
console.log("vueX中的方法触发");
|
||||||
|
},
|
||||||
|
setAsyncInfo(state) {
|
||||||
|
state.userInfo.name = "setTimeOut";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {},
|
// 异步调用mutations中的方法更改state状态 并不能直接更改
|
||||||
|
actions: {
|
||||||
|
setData(context) {
|
||||||
|
setTimeout(() => {
|
||||||
|
context.commit("setAsyncInfo");
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
//state中的数据做过滤等简单处理
|
||||||
getters: {},
|
getters: {},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,5 +4,17 @@
|
|||||||
* @Author: Ruin 🍭
|
* @Author: Ruin 🍭
|
||||||
* @Date: 2022-03-10 10:11:16
|
* @Date: 2022-03-10 10:11:16
|
||||||
* @LastEditors: 刘引
|
* @LastEditors: 刘引
|
||||||
* @LastEditTime: 2022-03-10 10:11:17
|
* @LastEditTime: 2022-03-10 17:51:03
|
||||||
-->
|
-->
|
||||||
|
<template>
|
||||||
|
<div class="root">我是home组件的子组件news</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.content {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -4,48 +4,18 @@
|
|||||||
* @Author: Ruin 🍭
|
* @Author: Ruin 🍭
|
||||||
* @Date: 2022-03-10 10:11:06
|
* @Date: 2022-03-10 10:11:06
|
||||||
* @LastEditors: 刘引
|
* @LastEditors: 刘引
|
||||||
* @LastEditTime: 2022-03-10 13:02:31
|
* @LastEditTime: 2022-03-10 17:50:33
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div class="root-home">
|
<div class="root-home">
|
||||||
<p>写一点demo玩一玩</p>
|
<p>我是home组件</p>
|
||||||
<el-button @click="getData()">{{ res }}</el-button>
|
<el-button>按钮</el-button>
|
||||||
<button @click="changeData()">更改值</button>
|
<news></news>
|
||||||
<div v-for="(item, index) in moreRes">{{ index }}==={{ item.title }}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onBeforeMount, onDeactivated, onMounted, onUpdated, reactive, ref } from 'vue';
|
import { computed, watch, onUpdated, ref, reactive } from 'vue';
|
||||||
let res = ref('我是响应式数据')
|
import news from './components/news.vue'
|
||||||
let moreRes = reactive([{ title: '我是复杂数据' }, { title: '我是复杂数据' }, { title: '我是复杂数据' }])
|
|
||||||
const getData = () => {
|
|
||||||
console.log('出发一下');
|
|
||||||
moreRes[0].title = '123'
|
|
||||||
for (let i of moreRes) {
|
|
||||||
console.log(i);
|
|
||||||
}
|
|
||||||
// console.log(moreRes);
|
|
||||||
}
|
|
||||||
const changeData = () => {
|
|
||||||
res.value = '呵呵'
|
|
||||||
console.log(res.value);
|
|
||||||
console.log('触发');
|
|
||||||
}
|
|
||||||
// localStorage.setItem('key', res)
|
|
||||||
|
|
||||||
onBeforeMount(() => {
|
|
||||||
console.log('dom渲染之前触发');
|
|
||||||
})
|
|
||||||
onMounted(() => {
|
|
||||||
console.log('dom渲染完毕时触发')
|
|
||||||
})
|
|
||||||
onUpdated(() => {
|
|
||||||
console.log('在界面数据更改时会触发');
|
|
||||||
})
|
|
||||||
onDeactivated(() => {
|
|
||||||
console.log('组件销毁时触发');
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -4,17 +4,27 @@
|
|||||||
* @Author: Ruin 🍭
|
* @Author: Ruin 🍭
|
||||||
* @Date: 2022-03-10 10:11:06
|
* @Date: 2022-03-10 10:11:06
|
||||||
* @LastEditors: 刘引
|
* @LastEditors: 刘引
|
||||||
* @LastEditTime: 2022-03-10 10:58:49
|
* @LastEditTime: 2022-03-10 16:05:04
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div class="root-home">
|
<div class="root-home">
|
||||||
<news></news>
|
<news></news>
|
||||||
|
<el-button @click="changeData()">更改值了</el-button>
|
||||||
<h1>写一点demo玩一玩</h1>
|
<h1>写一点demo玩一玩</h1>
|
||||||
|
{{ res }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import news from "./components/news.vue"
|
import news from "./components/news.vue"
|
||||||
|
import { useStore } from 'vuex';
|
||||||
|
import { computed } from "vue";
|
||||||
|
const store = useStore()
|
||||||
|
let res: any = computed(() => store.state.userInfo.name)
|
||||||
|
const changeData = () => {
|
||||||
|
store.dispatch('setData')
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* @Author: Ruin 🍭
|
* @Author: Ruin 🍭
|
||||||
* @Date: 2022-01-25 16:22:24
|
* @Date: 2022-01-25 16:22:24
|
||||||
* @LastEditors: 刘引
|
* @LastEditors: 刘引
|
||||||
* @LastEditTime: 2022-01-25 18:07:10
|
* @LastEditTime: 2022-03-10 16:34:39
|
||||||
*/
|
*/
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
|
|||||||
Reference in New Issue
Block a user