-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vant-weapp 无法绑定 readonly,class 等以关键字命名的属性到组件 #10337
Comments
为什么没人理这个 issue 呢? @Chen-jj |
遗漏了,我们看看 |
断点进入 Vue3 patch DOM 的部分,可以发现对于 <template>
<view class="index">
<van-field ref="field" :value="msg" label="姓名" maxlength="30" />
</view>
</template>
<script lang="ts">
import { ref, onMounted } from 'vue'
export default {
setup() {
const field = ref()
onMounted(() => {
// 手动 setAttribute
const el = field.value
el.setAttribute('readonly', true)
})
return {
field
}
}
}
</script> |
那 class 和 filter 的情况呢? |
这点下一个版本修复 |
实际上 Taro 是有把该函数进行 setData 的: 但可能小程序没有很好地适配这种 setData 写法,令到最终这个 filter 是 试了一下,只有这样 setData,才能正确设置 function: 因此开发者可以这样绕过此问题(下个版本开始支持): <template>
<view class="index">
<van-datetime-picker type="datetime" :filter="filter" />
</view>
</template>
<script lang="ts">
import { ref } from 'vue'
import Taro from '@tarojs/taro'
export default {
setup() {
const filter = ref()
return {
msg,
filter
}
},
onReady () {
Taro.nextTick(() => {
console.log('nexttick: ', )
this.filter = (type: string, options: number[]) => {
if (type === 'minute') {
return options.filter(option => option % 5 === 0);
}
return options;
};
})
}
}
</script> |
thank you |
@Chen-jj React里怎么修复这个问题? |
React 里的 hack 写法:#8495 (comment) |
calendar组件里面的formatter函数没法传递,这个怎么解决? |
相关平台
微信小程序
复现仓库
https://github.com/HyperLife1119/taro-issue
小程序基础库: 2.19.4
使用框架: Vue 3
复现步骤
编译到微信小程序查看结果
相关代码:
期望结果
实际结果
环境信息
The text was updated successfully, but these errors were encountered: