iT邦幫忙

0

Vue的子組件會為什麼影響到不到父層?

  • 分享至 

  • twitterImage

https://codesandbox.io/s/busy-cache-ufv9w?file=/src/components/StepApplication.vue

原本要做的效果是 按 下一步 或是上一步 把 step0 >step1 >step2>step3.... 的
css 改變讓顏色變色
https://ithelp.ithome.com.tw/upload/images/20200926/20102891BhimUhe4W0.png

但是把裡面的路徑 變成組件之後 反而css 無法改變,
我有仔細看過下 vue template parent child root

所以把組件裡面 原本的
this.step 改成 this.$root.step 沒有影響到

恩 請問有什麼其他解法嗎?真的很抱歉....

看更多先前的討論...收起先前的討論...
沒變色的原因應該是,超連結重整了頁面
可以使用下面這個語法讓超連結無效
<a href="javascript:void(0)"
yolala iT邦新手 5 級 ‧ 2020-09-26 16:09:32 檢舉
恩好像沒有椰
另外 this.$root.step 要改回 this.step
在 html 用 step 不需要加 this
用 a 標籤請在 click 加上 prevent -> @click.prevent
((筆記,listennn08 大的解答比較好
yolala iT邦新手 5 級 ‧ 2020-09-26 22:59:10 檢舉
謝謝各位@@
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答