vue 在进入某一个页面的时候,created方法不执行,----亲测,通俗易懂
生活随笔
收集整理的這篇文章主要介紹了
vue 在进入某一个页面的时候,created方法不执行,----亲测,通俗易懂
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
今天在寫vue項目的時候遇到了這樣一個問題當我點擊某一個二級菜單的時候會進入到相應的頁面,但是這個頁面的created方法不執行
代碼如下:
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中,正確的做法應該是放到和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}) }總結
以上是生活随笔為你收集整理的vue 在进入某一个页面的时候,created方法不执行,----亲测,通俗易懂的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Vue怎么将后台(springboot)
- 下一篇: vue+springboot图片上传,a