vue 在进入某一个页面的时候,created方法不执行,----亲测,通俗易懂
生活随笔
收集整理的這篇文章主要介紹了
vue 在进入某一个页面的时候,created方法不执行,----亲测,通俗易懂
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
今天在寫vue項(xiàng)目的時(shí)候遇到了這樣一個(gè)問題當(dāng)我點(diǎn)擊某一個(gè)二級菜單的時(shí)候會進(jìn)入到相應(yīng)的頁面,但是這個(gè)頁面的created方法不執(zhí)行
代碼如下:
data(){return{uploadData: {userId: '123',}}}, methods: {resetEditFrom() {this.editForm = {}},created() {console.log("come in...............")const _this = thisthis.$axios.get("/User/imageUrl/"+sessionStorage.getItem("userId")).then(function (resp) {console.log(resp.data)_this.userInfo.avatar = resp.data})} }很明顯我將created方法放到了methods中,正確的做法應(yīng)該是放到和data()、method同級別,代碼如下:
data(){return{uploadData: {userId: '123',}}}, methods: {resetEditFrom() {this.editForm = {}} }, created() {console.log("come in...............")const _this = thisthis.$axios.get("/User/imageUrl/"+sessionStorage.getItem("userId")).then(function (resp) {console.log(resp.data)_this.userInfo.avatar = resp.data}) }總結(jié)
以上是生活随笔為你收集整理的vue 在进入某一个页面的时候,created方法不执行,----亲测,通俗易懂的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Vue怎么将后台(springboot)
- 下一篇: vue+springboot图片上传,a