方案一
使用components注册,这个跟Vue2是一样的
import {
Field,
CellGroup, Popup, Notify
} from 'vant';
export default defineComponent({
name: "NamePopup",
components: {
[Field.name]: Field,
[CellGroup.name]: CellGroup,
[Popup.name]: Popup,
},
setup(props, { emit }) {
}
});
<van-popup
v-model:show="showPopup"
position="bottom"
:style="{ height: '100%' }"
teleport="body"
>
<van-cell-group v-if="showPopup" inset>
<van-field
@input="updateInputVal"
v-model="nameDec"
rows="2"
autosize
type="textarea"
maxlength="10"
/>
</van-cell-group>
</van-popup>
方案二
怎么引入,怎么使用,下面这个方案更常用一些,现在常用script+setup的模式
<script setup>
import {
Field,
CellGroup, Popup, Notify
} from 'vant';
</script>
<template>
<Popup v-model:show="showPopup" position="bottom" :style="{ height: '100%' }" teleport="body">
<CellGroup inset>
<Field @input="updateInputVal" v-model="nameDesc" rows="2" autosize type="textarea" maxlength="10"
/>
</CellGroup>
</Popup>
</template>