vuejs-challenges icon indicating copy to clipboard operation
vuejs-challenges copied to clipboard

24 - 激活的样式-指令

Open undefined-zzk opened this issue 1 year ago • 0 comments

// 你的答案

`

/**

  • Implement the custom directive
  • Make sure the list item text color changes to red when the toggleTab is toggled

*/ const VActiveStyle = { mounted(el:HTMLElement,binding:DirectiveBinding){ const [style,isTrue]=binding.value watchEffect(()=>{ for(let key in style){ if(isTrue()){ el.style[key]=style[key] }else{ el.style[key]='' } } }) } }

const list = [1, 2, 3, 4, 5, 6, 7, 8] const activeTab = ref(0) function toggleTab(index: number) { activeTab.value = index }

`

undefined-zzk avatar Feb 06 '24 11:02 undefined-zzk