You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside script-setup, use a ref attribute in template with a non-existant backing field.
To make use of that ref, you can use $refs in an event handler.
The linked repro uses <input ref="input"> and @click="$refs.input.focus()".
What is expected?
Probably should work.
At least should be consistent in dev vs build mode. Ideally consistent with script-classic, too.
What is actually happening?
It works in almost all situations:
Always works with classic script;
Works with script-setup in dev.
Fails in script-setup when deployed with build.
The reason it fails is because the script-setup codegen is different between dev and build.
In repro, you can see that ref="input" was simply translated to line 20: ref: input.
Except input is a free variable that is not declared.
All other cases have a different codegen that don't require a global variable (and the ref is usable from $refs).
The text was updated successfully, but these errors were encountered:
Version
3.2.4
Reproduction link
https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHNjcmlwdCBzZXR1cD5cbmltcG9ydCB7IHJlZiB9IGZyb20gJ3Z1ZSdcblxuY29uc3QgbXNnID0gcmVmKCdIZWxsbyBXb3JsZCEnKVxuPC9zY3JpcHQ+XG5cbjx0ZW1wbGF0ZT5cbiAgPGgxPnt7IG1zZyB9fTwvaDE+XG4gIDxpbnB1dCB2LW1vZGVsPVwibXNnXCIgcmVmPVwiaW5wdXRcIiAvPlxuICA8YnV0dG9uIEBjbGljaz1cIiRyZWZzLmlucHV0LmZvY3VzKClcIj5cbiAgICBGb2N1cyBpbnB1dFxuICA8L2J1dHRvbj5cbjwvdGVtcGxhdGU+In0=
Steps to reproduce
Inside script-setup, use a
ref
attribute in template with a non-existant backing field.To make use of that ref, you can use
$refs
in an event handler.The linked repro uses
<input ref="input">
and@click="$refs.input.focus()"
.What is expected?
Probably should work.
At least should be consistent in dev vs build mode. Ideally consistent with script-classic, too.
What is actually happening?
It works in almost all situations:
Fails in script-setup when deployed with build.
The reason it fails is because the script-setup codegen is different between dev and build.
In repro, you can see that
ref="input"
was simply translated to line 20:ref: input
.Except
input
is a free variable that is not declared.All other cases have a different codegen that don't require a global variable (and the ref is usable from
$refs
).The text was updated successfully, but these errors were encountered: