babel-plugin-jsx icon indicating copy to clipboard operation
babel-plugin-jsx copied to clipboard

[Question] Help 短横线插槽名称如何转换成jsx插槽函数名?

Open wilikeit opened this issue 2 years ago • 1 comments

🧐 Problem Description

短横线插槽名称在jsx中转换成驼峰写法,无法成功解析插槽

💻 Sample code

子组件 Child.vue

<div>我是子组件,下面是父组件的插槽内容:</div> <slot name="my-title" ></slot>

父组件 : 下面写成 myTitle,无法成功解析插槽

    <Child
      v-slots={{
        myTitle:()=> <div>mytitle插槽</div>
      }}
    />

🚑 Other information

wilikeit avatar Jul 21 '22 02:07 wilikeit

@wilikeit, did you try this ?

<Child
  v-slots={{
    'my-title': ()=> <div>mytitle插槽</div>
  }}
/>

funny-family avatar Sep 15 '22 03:09 funny-family

@wilikeit, did you try this ?

<Child
  v-slots={{
    'my-title': ()=> <div>mytitle插槽</div>
  }}
/>

Good job! 万万没想到直接打个 引号就行,我老是想着转换成驼峰法,思路狭隘了

wilikeit avatar Jun 28 '23 13:06 wilikeit