placeholder不显示and模板字符串无效

一、placeholder="请输入"不显示请输入?

input框里写了placeholder为什么不显示呢?

检查代码,input是否有初始值

在 Vue.js 中,v-model 是双向绑定的语法糖,它会动态更新输入框的 value。如果绑定的数据有初始值(非空),placeholder 就不会显示,因为它只在输入框内容为空时生效。


// 检查
data() {
  return {
    inputValue: null  // 或 undefined、''
  };
}
// 检查
created(){}
this.$set()

 二、placeholder="`${text}`"不显示text?

input框里写了placeholder,并且placeholder里写模板字符串为什么没用?

第一保证格式正确,第二动态绑定要v-bind;

在 Vue 中,需要用 v-bind(或 :)动态绑定 placeholder

你可能感兴趣的:(placeholder不显示and模板字符串无效)