我想问你是怎么解决这个问题的?
:birthdate="{{ $user->profile->birthdate->format('m-d-Y') }}"在我的模型中,我有这个
/**
* The attributes that should be cast to native types.
*
* @var array
*//**
*/
protected $dates = [
'birthdate',
];我想在我的vue模板中将其作为道具传递
props : {
birthdate : {
type : String,
required : true ,
default : null
}
}但是我得到了一个依赖于属性的计算..看看这个:生日属性,我告诉过你,如果我把它放在m/d/Y上,它会把整个东西分成两部分,如果是12/21/2019,它就会把它分成两部分,如果是12-21-2019,它会在传递给vue模板时减去整个部分
发布于 2019-12-22 23:31:13
尝试删除vue binding :,并将其用作:
birthdate="{{ $user->profile->birthdate->format('m-d-Y') }}"或者保留:,但将字符串括在单引号中。
:birthdate="'{{ $user->profile->birthdate->format('m-d-Y') }}'"或赋值给变量
:birthdate="myVar"
data(){
return{ myVar: "{{ $user->profile->birthdate->format('m-d-Y') }}"};
}因为:或v-bind需要表达式/变量,所以当您从PHP回显{{ $user->profile->birthdate->format('m-d-Y') }} as 12-21-2019时,vue将被视为带有减法的整数,而不是字符串。
https://stackoverflow.com/questions/59445334
复制相似问题