vue中的循環(huán)對(duì)象屬性和屬性值用法
v-for除了可以循環(huán)數(shù)組,還可以循環(huán)對(duì)象。
例子:
<template><div> <div v-for='(item,i) in obj'>{{i}}--{{item}}</div></div></template><script>export default { name: 'HelloWorld', data () { return { obj:{ age:1, name:'zs', sex:'男' } }; }}</script><style lang='css' scoped></style>
結(jié)果:
補(bǔ)充知識(shí):Vue控制路由滾動(dòng)行為
跳轉(zhuǎn)路由時(shí),要求跳轉(zhuǎn)到指定路由的某個(gè)地方,可以使用scrollBehavior方法控制。
用法:
scrollBehavior(to,from,savedPosition){ }
scrollBehavior方法可以返回x,y 坐標(biāo)點(diǎn),也可以返回指定的選擇器
例子:
import Vue from ’vue’import Router from ’vue-router’ import Home from ’../../view/Home.vue’ import Test from ’../../view/Test.vue’ import News from ’../../view/News.vue’Vue.use(Router)export default new Router({ routes: [ { name:'Home', component:Home, path:'/' }, { name:'Test', component:Test, path:'/test' }, { name:'News', component:News, path:'/news' }, { path:'*', redirect:'/' } ], mode:'history', //跳轉(zhuǎn)到指定路由的指定坐標(biāo) scrollBehavior(to,from,savedBehavior){ if(to.path==='/test'){ return { x:0, y:100 } }; // 跳轉(zhuǎn)到指定的選擇器 if(to.path==='/news'){ return { selector:'.here' } } }})
以上這篇vue中的循環(huán)對(duì)象屬性和屬性值用法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 得到XML文檔大小的方法2. WMLScript的語法基礎(chǔ)3. 使用Spry輕松將XML數(shù)據(jù)顯示到HTML頁(yè)的方法4. ASP中if語句、select 、while循環(huán)的使用方法5. xml中的空格之完全解說6. ASP中解決“對(duì)象關(guān)閉時(shí),不允許操作?!钡脑幃悊栴}……7. 輕松學(xué)習(xí)XML教程8. html小技巧之td,div標(biāo)簽里內(nèi)容不換行9. XML入門的常見問題(四)10. msxml3.dll 錯(cuò)誤 800c0019 系統(tǒng)錯(cuò)誤:-2146697191解決方法
