Giter Club home page Giter Club logo

Comments (4)

wuhy avatar wuhy commented on May 14, 2024

关于这个问题,可能文档上没写清楚,由于 okam 框架是渐进式增强,因此如果需要使用 watch 能力,需要在构建配置 framework 增加配置项:['data', 'watch'],所以请先确认下是否有加上相关配置。

from okam.

nyrf avatar nyrf commented on May 14, 2024

这个加上了,不报错,不过从父组件传过来的props更新后,watch没有任何变化 ,

   framework: [
        'data',
        'ref',
        'watch'
    ],

index.vue

<template>
    <view>
        <div @click='update'>Click check</div>
    </view>
</template>
<script>
import Hello from '../../components/Hello';
export default {
    config: {
        title: 'Page Title'
    },

    components: {
        Hello
    },
     data: {
       title: 'title'
    },

   methods: {
    update () {
            this.title = 'title updated'
       },
   }
   
}
</script>
<template>
    <view class="hello-wrap">
        {{title}}
    </view>
</template>
<script>
export default {
    config: {
    },

    props: {
        title: String
    },

   created() {
     this.$watch('title', function (newVal, oldVal) {
          console.log('watch', newVal, oldVal, 'donw')
      });
   },

    data: {
    },

    methods: {

    }
};
</script>

点击页面上的update,子组件title看着是更新了,但watch这里newVal和oldVal都是空

from okam.

wuhy avatar wuhy commented on May 14, 2024

还有明确下是微信下还是?我这边在百度小程序、微信小程序都没有问题,支付宝小程序由于不支持 props observer 所以目前有点问题

from okam.

nyrf avatar nyrf commented on May 14, 2024

我用的微信,昨晚一直不可以,今天可以了

from okam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.