nue icon indicating copy to clipboard operation
nue copied to clipboard

Reactive values are not updated? why?

Open yuhengliang opened this issue 1 year ago • 3 comments

<div @name="test">
    <p>Countdown: { countdown }</p>
    <script>
        countdown = 0
        mounted() {
            setInterval(() => {
                this.countdown++
                console.log(this.countdown)
            }, 1000)
        }
    </script>
</div>

The ' countdown ' not updated, why ? How do update automatically?

yuhengliang avatar Apr 11 '24 14:04 yuhengliang

can use ' this.update() ' , Are there other ways to update automatically?

yuhengliang avatar Apr 11 '24 14:04 yuhengliang

<div @name="test">
    <layout>
        <p>Countdown: { countdown }</p>
    </layout>
    <script>
        countdown = 0
        mounted() {
            setInterval(() => {
                this.countdown++
                console.log(this.countdown)
                this.update()
            }, 1000)
        }
    </script>
</div>

layout is custom component ,

<div @name="layout">
    <slot />
</div>

use this.update(), but, The ' countdown ' not updated to, why ? How do update automatically?

yuhengliang avatar Apr 11 '24 14:04 yuhengliang

I have similar problem with :if:

<label :if="condition"><select @change="render"></select></label>
<script>
render() {
  this.update({ foo: 'bar' })
  // won't work, because inside the `createApp` for `:if`
 // the `Impl` is undefined but not the parent view

  this.foo = 'bar' // works
}
</script>

fritx avatar Apr 17 '24 06:04 fritx