uni-app
uni-app copied to clipboard
defineModel 无法使用,提示 "useModel" is not exported
"useModel" is not exported by "node_modules/.pnpm/@[email protected]/node_modules/@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js", imported by "src/components/categories/CategoryScrollSelector.vue?vue&type=script&setup=true&lang.ts". at components/categories/CategoryScrollSelector.vue:1:9 1: import { useModel as _useModel, defineComponent as _defineComponent } from 'vue' ^ 2: import { unref as _unref, toDisplayString as _toDisplayString, t as _t, o as _o, f as _f, n as _n } from "vue"
+1
+1
+1
+1
@fxy060608 h5可以使用了, 但是微信小程序还是不行
有朋友测过了? 现在怎么样了?
我测试微信小程序,运行 ok,可以参考下面 demo 运行
https://gitcode.net/xiurensha5731/uni-app-questions/-/blob/main/src/pages/index/index.vue
index page
<template>
<div>
<div>你输入了:{{ str }}</div>
<myInput v-model:count="str"></myInput>
</div>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import myInput from "../../components/my-input.vue";
const str = ref("2");
</script>
对应组件 my-input
<template>
<div>
<input
type="text"
v-model="count"
style="height: 20px; border: 1px solid black"
/>
</div>
</template>
<script lang="ts" setup>
const count = defineModel<string>("count", { default: "" });
</script>
<style></style>