A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/vuejs/vue-next/issues/3625 below:

@onclick="v+=1" for ref v declared as var/let does not increment. <script setup> · Issue #3625 · vuejs/core · GitHub

Version

3.0.11

Reproduction link

sfc playground

Steps to reproduce

trigger @click for button with v+=1 expression two times.
1st time it will reset v to 1
2nd time and onward it will stay 1

What is expected?

it is expected that v+=1 will increment value of v by 1 every time @click is triggered.

The same way v=v+1 or v++ works

What is actually happening?

v+=1 always sets the value to 1 and does not increment

vue: v3.0.11

for a var/let v = ref()

v += 1 is compiled to:

    _createVNode("button", {
      onClick: _cache[3] || (_cache[3] = $event => (_isRef(v) ? v.value = 1 : v+=1))
    }, "v += 1"),

for a const c = ref()

 _createVNode("button", {
      onClick: _cache[6] || (_cache[6] = $event => (c.value += 1))
    }, "c += 1")

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4