taro
taro copied to clipboard
父子组件props值改变 子组件模版未更新
相关平台
支付宝小程序
复现仓库
https://github.com/pangcongcong/demo/blob/main/parent.vue 小程序基础库: 1.0.0 使用框架: Vue 3
复现步骤
父组件下滑到一定高度改变子组件悬浮状态(onPageScroll监听),父子组件数据都改变了,但是子组件模版未更新,悬浮class未加上。this.$forceupdate()也不行。
期望结果
子组件模版重新渲染
实际结果
子组件模版首次渲染后不再重绘
环境信息
Taro CLI 3.3.0 environment info:
System:
OS: macOS 11.3.1
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.15.0 - /usr/local/bin/node
npm: 6.14.8 - /usr/local/bin/npm
npmPackages:
@tarojs/cli: ^3.3.0 => 3.3.0
@tarojs/components: ^3.3.0 => 3.3.0
@tarojs/mini-runner: ^3.3.0 => 3.3.0
@tarojs/plugin-platform-alipay: ^3.3.0 => 3.3.0
@tarojs/plugin-platform-jd: ^3.3.0 => 3.3.0
@tarojs/plugin-platform-qq: ^3.3.0 => 3.3.0
@tarojs/plugin-platform-swan: ^3.3.0 => 3.3.0
@tarojs/plugin-platform-tt: ^3.3.0 => 3.3.0
@tarojs/plugin-platform-weapp: ^3.3.0 => 3.3.0
@tarojs/runtime: ^3.3.0 => 3.3.0
@tarojs/taro: ^3.3.0 => 3.3.0
@tarojs/webpack-runner: ^3.3.0 => 3.3.0
babel-preset-taro: ^3.3.0 => 3.3.0
eslint-config-taro: ^3.3.0 => 3.3.0
@pangcongcong 没有复现
滚动前:

滚动后:

index.vue
<template>
<view>
<searchInput :searchFixed="searchFixed"></searchInput>
<view style="height: 1200px">---</view>
</view>
</template>
<script lang="ts">
import searchInput from './searchInput.vue'
export default {
components: {
searchInput
},
data() {
return {
searchFixed: false
};
},
onPageScroll(e){
if (e.scrollTop > 300 ) {
this.searchFixed = true
}
},
methods: {
},
};
</script>
searchInput.vue
<template>
<input :class="[searchFixed ? 'class-fixed' : '']" style="border: 1px solid red"/>
</template>
<style>
.class-fixed {
position: fixed;
top: 0;
}
</style>
<script lang="ts">
export default {
props: {
searchFixed: {
type: Boolean
}
},
data() {
return {
};
},
methods: {
},
};
</script>