laravel - 用空字符串替换 NULL 值 Vue

标签 laravel vue.js

有什么方法可以将 vue 中显示的 null 值替换为空字符串吗?

<template>
<div class="flexItem">
      <ui-textbox label="Address" v-model="customer.address"
          :disabled="disabled"
          name="address"
          @input="update()"
          v-validate="'max:255'"
      ></ui-textbox>
</div>
</template>

export default{
name: 'customer',
props:{
    value:{
        type:Object,
        required:true,
    },
    disabled:{
        type:Boolean,
        default:false,
    }
},
data(){
    return {
        customer:{
            address:"",
        }
    },
methods:{
    update(){
        this.$emit('input',this.customer);
    },
}

现在显示值是null,但我希望将其替换为空字符串。 enter image description here

有什么办法可以做到这一点吗?

最佳答案

我认为这将迫使您转储 v-model 并分别对绑定(bind)的两侧进行编码。所以...

<ui-textbox 
    :value="customer.address || ''" 
    @input="customer.address = event.target.value"
    ...

关于laravel - 用空字符串替换 NULL 值 Vue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49687110/

相关文章:

javascript - sql count函数返回对象作为laravel中的输出

javascript - 在 VueJS 中使用 Axios - 这个未定义

css - 如何从 json 数据设置动态类名?

html - 无法为 Framework7 + Vue App 设置主体背景颜色

php - 连接被拒绝 SQL : select * from information_schema. 表,其中 table_schema = firstdb 和 table_name = migrations 和 table_type = 'BASE TABLE

php - 从数据透视表创建 hasMany 或一对多关系 - Laravel

php - 将 id 参数传递给 Laravel 中的资源

php - 如何在laravel 5.5中获取网络路由列表?

javascript - 数组上未检测到 Vue 更改

vue.js - 在 Nuxt 应用程序中为动态路由生成 xml 站点地图