typeScript小记

vue3+ts
1.页面属性值
ps:vue3中ref和reactive的区别:https://www.cnblogs.com/theblogs/p/16965285.html

const searchValue = ref<string>("hhhh");//与页面html双向绑定
const searchValue: string = "哈哈哈";//无法双向绑定

2.props
defineProps 只能在 < setup> 中使用,无需导入

const props = defineProps({
  isShowCheckBox: {
    type: Boolean, // 参数类型
    default: false, //默认值
    required: false, //是否必传
  },
  tableData: {
    type: Array, // 参数类型
    default: function () {
      return []
    },
    //默认值
    required: true, //是否必传
  },
});

你可能感兴趣的:(typeScript,vue,typescript,javascript,前端)