APP.vue里面使用了mounted contact組件里面也使用了mounted 我首頁設(shè)置的是/home 在首頁改變大小會(huì)彈出1 如果在切換到/contact下只能彈2 我想在子組件contact中改變大小時(shí)同時(shí)讓1也彈出來應(yīng)該怎么辦呢?下面這樣的布局下能做到嗎?PS:后來我發(fā)現(xiàn)一個(gè)現(xiàn)象 就是我把contact組件中的mounted去掉 當(dāng)再切換到組件contact中改變大小時(shí)App.vue里面的mounted就能生效了 可以彈出1 但是兩個(gè)mounted為什么不能同時(shí)生效?App.vue<template>
<div id="app">
<div class="nav">
<span><router-link to="/home">首頁</router-link></span>
<span><router-link to="/product">產(chǎn)品</router-link></span>
<span><router-link to="/contact">聯(lián)系</router-link></span>
</div>
<div class="views">
<router-view/>
</div>
</div></template>mounted () {
window.onresize = () => {
return (() => {
alert(1)
})()
}
}contact.vuemounted () { window.onresize = () => { return (() => {
alert(2)
})()
}
}
添加回答
舉報(bào)
0/150
提交
取消