feat(compiler): ensure interpolation expressions are wrapped with toString()
This commit is contained in:
10
packages/runtime-core/src/helpers/toString.ts
Normal file
10
packages/runtime-core/src/helpers/toString.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { isArray, isPlainObject, objectToString } from '@vue/shared'
|
||||
|
||||
// for conversting {{ interpolation }} values to displayed strings.
|
||||
export function toString(val: any): string {
|
||||
return val == null
|
||||
? ''
|
||||
: isArray(val) || (isPlainObject(val) && val.toString === objectToString)
|
||||
? JSON.stringify(val, null, 2)
|
||||
: String(val)
|
||||
}
|
||||
Reference in New Issue
Block a user