vue变量?
来源:9-19 完善车次&车厢&座位管理功能

慕神4535282
2023-05-09
老师,下午好!
请教一个问题,本节中,
export default defineComponent({
name: "train-select-view",
props: ["modelValue", "width"],
emits: ['update:modelValue', 'change'],
setup(props, {emit}) {
const trainCode = ref();
const trains = ref([]);
const localWidth = ref(props.width);
if (Tool.isEmpty(props.width)) {
localWidth.value = "100%";
}
...
return {
trainCode,
trains,
filterTrainCodeOption,
onChange,
localWidth
};
}
这里的 localWidth 是属于什么变量,局部变量,内部变量,这里localWidth 在setup()函数内定义,但是却可以在html中使用它,是因为 return { localWidth} 吗? 这里的 props: [“modelValue”, “width”], 中的width又叫做什么变量,谢谢老师解答!!!
写回答
1回答
-
localWidth是组件内的响应式变量,或叫绑定变量,用于html和js交互的,width没啥名,用于父子组件数据传递的属性
012023-05-12
相似问题