Skip to content

vModel: __currentInstance.$set is not a function #699

@Tarrowren

Description

@Tarrowren
// error
import { defineComponent, ref } from "@vue/composition-api";

export const App = defineComponent({
  name: "App",
  setup: () => {
    const name = ref("");
    return () => (
      <div>
        <div>{name.value}</div>
        <input type="text" vModel={name.value} />
      </div>
    );
  }
});

When I input, it throws:
image


TypeError: __currentInstance.$set is not a function
at input (App.tsx?1c6d:8)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at HTMLInputElement.invoker (vue.runtime.esm.js?2b0e:2179)
at HTMLInputElement.original.\_wrapper (vue.runtime.esm.js?2b0e:6917)

// It's OK to write like this
import { defineComponent, ref } from "@vue/composition-api";

export const App = defineComponent({
  name: "App",
  setup() {
    const name = ref("");
    return { name };
  },
  render() {
    return (
      <div>
        <div>{this.name}</div>
        <input type="text" vModel={this.name} />
      </div>
    );
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions