【发布时间】:2021-03-23 15:05:44
【问题描述】:
我真的很喜欢 Vue 组件中的 props: ['title', 'someInt', 'description'] 语法。我如何只需要这些道具中的 1 个,即 someInt,作为整数?但不必显式定义其他道具的数据类型(它们可以保持默认为字符串)。
我的父组件正在执行<my-component title='some title' some-int='100' description='desc'></my-component>,后来当我执行this.someInt 时,它的数据类型是字符串而不是整数(数字)。谢谢!
【问题讨论】:
标签: vue.js vuejs2 vue-component