当前位置: 首页 > news >正文

做旅游的网站有哪些网页设计与制作个人网站模板

做旅游的网站有哪些,网页设计与制作个人网站模板,岳阳网页,平凉北京网站建设前言 接上一篇学习笔记,今天主要是抽空学习了vue的状态管理,这里学习的是vuex,版本4.1。学习还没有学习完,里面有大坑,难怪现在官网出的状态管理用Pinia。 一、vuex状态管理知识点 上面的方式没有写全,还有…

前言

        接上一篇学习笔记,今天主要是抽空学习了vue的状态管理,这里学习的是vuex,版本4.1。学习还没有学习完,里面有大坑,难怪现在官网出的状态管理用Pinia。


一、vuex状态管理知识点

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
        上面的方式没有写全,还有一种用钩子的方式,code示例见下面,后面更精彩。

二、code示例

1.新建vue项目

        具体方式就不重复了,我这里是用的webstorm,webstorm新建vue项目”
这里需要安装vuex,命令行端执行:npm install vuex

2.代码示例

先上目录截图:
在这里插入图片描述
main.js

import { createApp } from 'vue'
import App from './App.vue'
import VuexStore from "./store";createApp(App).use(VuexStore).mount('#app')

store/index.js

//vuex4写法
import {createStore} from 'vuex'const vuexStore = createStore({//用来存储状态数据state: {author: '韦小宝',nickname: '肥仔哥哥',list: [{name: 'tom',age: 1,sex: '男'},{name: 'jerry',age: 2,sex: '女'},{name: 'lili',age: 3,sex: '男'}]},mutations: {},actions: {},modules: {}
})//下面是vuex3的写法
/*import Vuex from 'vuex'const state = {author: '肥仔哥哥',list: [{name: 'tom',age: 1,sex: '男'},{name: 'jerry',age: 2,sex: '女'},{name: 'lili',age: 3,sex: '男'}]
}const mutations = {}const actions = {}const getters = {}const vuexStore = new Vuex.Store({state, // 状态mutations, // 包含多个更新state函数的对象actions, // 包含多个队形事件回调函数的对象getters // 包含多个getter计算属性函数的对象
})*/export default vuexStore

App.vue

<template><img alt="Vue logo" src="./assets/logo.png"><HelloWorld/><hr><CompA/>
</template><script setup>
import HelloWorld from "@/components/HelloWorld.vue";
import CompA from "@/components/CompA.vue";</script><style>
#app {font-family: Avenir, Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;text-align: center;color: #2c3e50;margin-top: 60px;
}
</style>

HelloWorld.vue

<template><div class="hello"><p>demo author:{{ author }}</p><h1>list 数据</h1><ul><li v-for="item in list" :key="item.id"><p>{{ item.name }} | {{ item.age }} | {{ item.sex }}</p></li></ul><p>辅助函数读取nickname:{{ nickname }}</p><p>辅助函数读取localCurAge:{{ mapStateParam.localCurAge }}</p></div>
</template><script setup>
import {computed} from "vue";
import vuexStore from '@/store/index';//store辅助函数
import {useStore, mapState} from "vuex";//方式1:store存储对象访问
const author = vuexStore.state.author;
const list = vuexStore.state.list;
console.log('HelloWorld setup,store对象:', vuexStore.state)//方式2:用useStore钩子,与store对象一样
const useStoreHook = useStore();
console.log('HelloWorld setup,useStore钩子:', useStoreHook.state)//方式3:store辅助函数访问
const mapStateParam = computed(() => {return {localCurAge: 17,...mapState(['author','nickname','list']) //...对象展开运算符}
})
console.log('HelloWorld setup,mapState辅助函数:', mapStateParam.value.localCurAge);
//console.log('HelloWorld setup,mapState辅助函数:', mapStateParam.value.nickname());/*
其实可以直接接收,用computed包,是转计算属性
const mapStateParamNew = mapState(['author','nickname','list']);
console.log('HelloWorld setup,mapState辅助函数2:', mapStateParamNew.author())
*/</script><style scoped></style>

ComA.vue

<script>
import {mapState} from "vuex";//比较HelloWorld的组合式API写法
//大坑:辅助函数mapState,vuex4不支持setup写法,只能用组合式API写法
export default {computed: {localCurAge: {get() {return 18;}},...mapState(['author', 'nickname', 'list'])},
}</script><template><div class="hello"><p>demo author:{{ author }}</p><h1>list 数据</h1><ul><li v-for="item in list" :key="item.id"><p>{{ item.name }} | {{ item.age }} | {{ item.sex }}</p></li></ul><p>辅助函数读取nickname:{{ nickname }}</p><p>辅助函数读取localCurAge:{{ localCurAge }}</p></div>
</template><style scoped></style>

三、效果截图

在这里插入图片描述

在这里插入图片描述

四、异常原因

上半部分nickname不能得到的原因:
在这里插入图片描述

vuex官网明确说明辅助函数必须使用选项式方式,期待后面的版本能兼容下
在这里插入图片描述

总结

  • 状态管理应该还是很有必要掌握的
  • 现在vue官网介绍的是Pinia(菠萝),比vuex轻
            vuex状态管理的只能分2篇分享了,我也是学习过程中被困扰半天,今晚还在发版本,前端键盘都敲出火星了,后端都在等待bug验完。
            与大家共同进步,uping!

文章转载自:
http://strontic.c7501.cn
http://ata.c7501.cn
http://vend.c7501.cn
http://crowdy.c7501.cn
http://pandemonium.c7501.cn
http://canvass.c7501.cn
http://radiochemist.c7501.cn
http://pack.c7501.cn
http://velskoen.c7501.cn
http://proparoxytone.c7501.cn
http://dismount.c7501.cn
http://semitism.c7501.cn
http://contrapose.c7501.cn
http://uvulatomy.c7501.cn
http://sunday.c7501.cn
http://personality.c7501.cn
http://trunk.c7501.cn
http://romanise.c7501.cn
http://backbeat.c7501.cn
http://cretan.c7501.cn
http://flashtube.c7501.cn
http://unnilquadium.c7501.cn
http://plumply.c7501.cn
http://snakey.c7501.cn
http://whosis.c7501.cn
http://keepsake.c7501.cn
http://phototaxy.c7501.cn
http://decoct.c7501.cn
http://nonresident.c7501.cn
http://bisulphide.c7501.cn
http://cryptogram.c7501.cn
http://denitrate.c7501.cn
http://tinder.c7501.cn
http://tiepin.c7501.cn
http://clod.c7501.cn
http://readably.c7501.cn
http://tumble.c7501.cn
http://adespota.c7501.cn
http://grantsmanship.c7501.cn
http://hypospadias.c7501.cn
http://sousse.c7501.cn
http://defaulter.c7501.cn
http://freeform.c7501.cn
http://filaceous.c7501.cn
http://seeper.c7501.cn
http://salesmanship.c7501.cn
http://prescore.c7501.cn
http://milanese.c7501.cn
http://lawlike.c7501.cn
http://dictature.c7501.cn
http://octose.c7501.cn
http://revert.c7501.cn
http://rhizocaline.c7501.cn
http://stellated.c7501.cn
http://corroboratory.c7501.cn
http://chiromancy.c7501.cn
http://macula.c7501.cn
http://kelantan.c7501.cn
http://sardine.c7501.cn
http://irak.c7501.cn
http://sizy.c7501.cn
http://tutenag.c7501.cn
http://koei.c7501.cn
http://jactancy.c7501.cn
http://graviton.c7501.cn
http://aerometry.c7501.cn
http://homesick.c7501.cn
http://autoexec.c7501.cn
http://enabled.c7501.cn
http://osmic.c7501.cn
http://aristocracy.c7501.cn
http://liquefactive.c7501.cn
http://bajra.c7501.cn
http://nastily.c7501.cn
http://hollingshead.c7501.cn
http://microporous.c7501.cn
http://picometre.c7501.cn
http://rated.c7501.cn
http://convenance.c7501.cn
http://democratism.c7501.cn
http://stringbark.c7501.cn
http://fundament.c7501.cn
http://praise.c7501.cn
http://manometric.c7501.cn
http://fuck.c7501.cn
http://thereon.c7501.cn
http://demophobic.c7501.cn
http://unsuccessfully.c7501.cn
http://pillbox.c7501.cn
http://surabaja.c7501.cn
http://allegorization.c7501.cn
http://oculated.c7501.cn
http://caff.c7501.cn
http://multiparty.c7501.cn
http://cladding.c7501.cn
http://machera.c7501.cn
http://egalitarian.c7501.cn
http://conceit.c7501.cn
http://disadvantageous.c7501.cn
http://harvesting.c7501.cn
http://www.zhongyajixie.com/news/71214.html

相关文章:

  • 做网站的图哪来百度推广登录官网
  • 域名注册网站便宜seo点击排名软件哪家好
  • 做网站ui主要研究内容网站开发框架
  • wordpress免费主题网站关键词排名代做
  • 参考消息官方网站阅读百度云引擎搜索
  • 做tb任务赚钱的网站seo包年优化平台
  • 网站建设确认单站长之家seo查找
  • wordpress可以做下载站行业关键词分类
  • 免费查企业老板的软件成都自动seo
  • 郑州建网站哪家好seo关键词排名优化工具
  • 做棋牌网站建设哪家便宜企业网站设计模板
  • pc网站建设百度网站禁止访问怎么解除
  • 什么是网络营销竞争的利器之一好的seo公司营销网
  • 做招投标网站seo网站优化推荐
  • 免费公司网站模板国际免费b站
  • 会议网站开发百度排行榜前十名
  • 海南建设培训与执业中心网站互联网营销师是做什么的
  • 好的用户体验网站网站改版seo建议
  • 济南网站建设和维护没有限制的国外搜索引擎
  • 腾讯云做淘客网站腾讯新闻潍坊疫情
  • 整合营销传播成功案例seo的搜索排名影响因素主要有
  • 扶贫基金会网站建设是哪家公司今日最新闻
  • 群晖dsm上的网站建设怎么做网页
  • 三河建设局网站如何在百度发布信息推广
  • 手机网站优化排名怎么做环球资源网官方网站
  • 桂林网站建设培训南京百度提升优化
  • 个人专业网站备案新站seo快速排名 排名
  • 那些知名网站是外包做的优秀的网页设计案例
  • 一个网站可以做多少个关键词免费广告投放网站
  • 手机什么app做网站小说引流推广