您当前的位置: 首页 >  ios

暂无认证

  • 2浏览

    0关注

    92582博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

vue滚动视图、axios、get、then、catch

发布时间:2021-06-25 21:34:04 ,浏览量:2

目录
  • 1、html 部分
  • 2、JavaScript 部分
  • 3、css 部分
  • 4、演示
1、html 部分
<div id="app"> <div class="roll_box"> <div> <div class="menu_item" v-for="(item,i) in rollView" :key="item.id" v-text="item.title" @click="roll(i)"> el: "#app", data: { rollView: [], content: ['点击标题可以展示对应内容'] }, mounted() { this.getData(); }, methods: { getData() { let that = this; axios.get('../json/jsonData.json').then(response => { that.rollView = response.data.rollView; }).catch(reason => { console.log('出错啦'); }); }, roll(i) { this.content = this.rollView[i].content; } } }); 
3、css 部分
.roll_box { display: flex; justify-content: center; align-items: center; } .menu_item { margin-bottom: 16px; font-weight: 600; cursor: pointer; } .content_box { width: 60%; } .content_box { margin-left: 50px; } 
4、演示

1.1.3X

1.1.3P

关注
打赏
1653961664
查看更多评论
立即登录/注册

微信扫码登录

0.6190s