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

旅游网站结构图我国哪些网站是做调查问卷的

旅游网站结构图,我国哪些网站是做调查问卷的,电商网站里的水果图片怎么做的,网站前台空白日常开发记录-正确的prop传参#xff0c;reduce搭配promise的使用 1.正确的prop传参2.reduce搭配promise的使用 1.正确的prop传参 一般会的父组件传参子组件 //父组件 A :demodata.synctestData :listData.synctestData2/A data ()… 日常开发记录-正确的prop传参reduce搭配promise的使用 1.正确的prop传参2.reduce搭配promise的使用 1.正确的prop传参 一般会的父组件传参子组件 //父组件 A :demodata.synctestData :listData.synctestData2/A data () {return {testData: {content: ,textStyle: {fontsize: 14px,},},testData2: [{content: 11,textStyle: {fontsize: 14px,},},],}}, //子组件 el-input v-modeldemodata.content/el-input然后子组件v-model看着和使用起来是可以达到双向绑定的但是是不推荐这样改的。 //子组件 templatediv{{ demodata }}!-- 不要直接修改 props使用事件通知父组件更新 使用 .sync 修饰符或 v-model 实现双向绑定,这种感觉单个属性可以类似“监听”整个对象数组貌似不太行 --el-input :valuedemodata.content inputchangeInput/el-inputel-table :datalocalDatael-table-column propcontent label姓名/el-table-column/el-tableel-button clickadd添加/el-button/div /template script export default {props: {demodata: {type: Object,default: () { }},listData: {type: Array,default: () []}},data () {return {localData: [...this.listData]}},watch: {listData: {handler (newVal) {this.localData [...newVal]},deep: true}},mounted () {},methods: {changeInput (val) {this.$emit(update:demodata, {...this.demodata,content: val})}, add () {this.localData.push({ name: test })this.$emit(update:listData, [...this.localData])}} } /script还有种父组件v-model的写法 //父组件A v-modeltestData3/AtestData3: {content: ,textStyle: {fontsize: 14px,},},//子组件 templatediv{{ demodata }}el-input :valuedemodata.content inputupdateContent/el-input/div /template script export default {model: {prop: demodata,event: update:demodata},props: {demodata: {type: Object,default: () { }},},methods: {updateContent (val) {this.$emit(update:demodata, { ...this.demodata, content: val });}} } /script子组件的写法要注意model选项里的prop和event都是自定义的但是要一一对应。 在 Vue 2 中一个组件上默认只能使用一个 v-model。这是因为 v-model 在 Vue 2 中主要是作为语法糖用于简化父子组件间的双向数据绑定它默认绑定到子组件的 value 属性上并监听 input 事件除非通过 model 选项进行了自定义。 然而如果你需要在 Vue 2 中实现多个双向数据绑定你可以使用 .sync 修饰符作为替代方案。.sync 修饰符允许你绑定一个对象或多个属性并在子组件中通过触发特定格式的事件update:属性名来更新父组件中的数据。 2.reduce搭配promise的使用 logInOrder (urls) {const textPromises urls.map((url) {return fetch(url).then((response) response.json()) // 修改为 json() 因为返回的是 JSON 数据.then((data) JSON.stringify(data, null, 2)) // 格式化输出})console.log(log, textPromises)return textPromises.reduce((chain, textPromise) {console.log(chain, chain,textPromise, textPromise)return chain.then(() textPromise).then((text) {console.log(获取到的数据\n, text)console.log(------------------------)return text})}, Promise.resolve())},reduce里面的代码有点没太理解本来一般也少写特别是then(() textPromise)这没太看懂改下写法 logInOrder(urls) {const textPromises urls.map(url {return fetch(url).then(response response.json()).then(data JSON.stringify(data, null, 2));});return textPromises.reduce((chain, textPromise) {return chain.then(() {return textPromise.then(text {console.log(获取到的数据\n, text);console.log(------------------------);return text; });});}, Promise.resolve()); }现在看得清楚了多看一次的执行就是轮询调用promise.then。而且有return text和没有return text的每次chain也是不一样的。 //调用实例const a this.logInOrder([https://jsonplaceholder.typicode.com/posts/1,https://jsonplaceholder.typicode.com/posts/2,https://jsonplaceholder.typicode.com/posts/3,https://jsonplaceholder.typicode.com/posts/4,https://jsonplaceholder.typicode.com/posts/5])console.log(a, a)猜猜它的打印结果呢。 有点出乎我的意料。。。怎么也不会是这个结果嘛感觉。自己想的理想输出是先打印chain然后是获取到的数据最后再是a的值而且a也不应该是一个promise吧。这段代码里有很多的return第一个return是函数整体的返回值给return出去第二个return是reduce函数里传递给下一个的第三个return是为了按顺序将多个异步按顺序串起来。最后一个return是整个函数要返回的值。 之所以现在的打印结果是上面的这个其实可以当成先执行的同步再执行到异步代码。把最后的结果换个写法 async mounted () {const a await this.logInOrder([https://jsonplaceholder.typicode.com/posts/1,https://jsonplaceholder.typicode.com/posts/2,https://jsonplaceholder.typicode.com/posts/3,https://jsonplaceholder.typicode.com/posts/4,https://jsonplaceholder.typicode.com/posts/5])console.log(a, a)}, 或则 mounted () {this.logInOrder([https://jsonplaceholder.typicode.com/posts/1,https://jsonplaceholder.typicode.com/posts/2,https://jsonplaceholder.typicode.com/posts/3,https://jsonplaceholder.typicode.com/posts/4,https://jsonplaceholder.typicode.com/posts/5]).then(a {console.log(a, a)})},打印出来的结果就是我理想中的了。
http://www.hkea.cn/news/14506043/

相关文章:

  • 江门北京网站建设网站建设与管理论文的总结
  • 鞋图相册网站怎么做代做毕业设计的网站好
  • 大连鼎信网站建设公司江苏建设集团招聘信息网站
  • 手机网站怎么开发海洋高端的专业做网站
  • 建网站的费用是多少钱怎么做网站首页关键词
  • 做视频网站用哪个软件好wordpress修改底部版权信息
  • 保山网站建设优化如何提升网站pr值
  • 企业网站模板中文 产品列表四川微信网站建设推
  • 织梦笑话娱乐网站源码2w数据+36条采集规则安平网站建设优化
  • 商城网站建设推广服装网站建设开题报告
  • 手表网站错误怎么办多用户商城系统方案
  • 网站怎么让百度收录网页设计与制作商丘到的公司
  • 响应式网站代理网站可以换主机吗
  • 当年的51网站鲜花网站的网络营销与策划书
  • 网站论坛建设方案网站英文版怎么做
  • 高校网站建设意义自应式网站
  • 给你网站你会怎么做的工作证的照片几寸
  • 网站开发建设培训做网站语言服务器 空间
  • 三亚旅游网站策划书房地产行情最新消息
  • iis建立的网站打不开比较好的开源cms系统
  • 如何制作网站建设网络营销推广公司有哪些
  • 企业推广网站wordpress 后台无法登录
  • 网站源码大全 最新企业网站制作开发
  • 黑龙江省建设厅的网站建筑工程网格优化
  • 山东网站建设哪家好花生壳如何做网站
  • phpcms v9网站导航网页导航菜单设计
  • 南通网站建设公司哪个好韩国美食做视频网站
  • 网站建设设备预算网站域名空间合同
  • 大型网站设计公司xampp下安装wordpress
  • 定制程序网站金昌市建设局网站