When using the VUE filter, I encountered an error from the console: vue.esm.js?efeb:628 [Vue warn]: Error in render: "TypeError: Cannot read property 'toFixed' of undefined"
It is found that undefined is an error in the filtermoneyFilters.js
The reason for the error is because the filter is executed twice.
The first time is when no data is passed in the background, the filter function is executed once. And there is no data at this time, and the filter function passed into the filter function is undefined. The error is generated at this time
The second time is to pass data in the background.After rendering the data, the filter function is executed once.
The solution is to make a judgment in the filter to pass in the parameters. If the passed parameter is undefined or other values that are implicitly converted to false, the function will jump out and no longer be executed.
Code
export function toMoney ( money ) { if (!money) { //A data transfer judgment is performed here. If the passed in is a null value, return its empty string. Solve its problem return '' ; } return money.toFixed( 2 ); }
Read More:
- Vue error in render: “typeerror: cannot read property ‘length’ of undefined”
- [Vue warn]: Error in render: TypeError: Cannot read property ‘xxxx’of undefined
- [Solved] vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: “TypeError: Cannot read property ‘length‘
- [Solved] Vue + uniapp Uncaught TypeError: Cannot read property ‘getters‘ of undefined
- [Solved] Vue Error: Uncaught TypeError: Cannot read property ‘getters‘ of undefined
- Vue Error in callback for immediate watcher “height”: “TypeError: Cannot read property ‘style’ of
- [Solved] TypeError: Cannot read property ‘indexOf‘ of undefined at VueComponent.resetFields
- Wechat program typeerror: a solution to cannot read property ‘SetData’ of undefined
- Vue ElementUI el-dropdown Error: Uncaught TypeError: Cannot read property ‘disabled‘ of null
- VUE Echarts Loading Error TypeError: Cannot read property getAttribute of null?
- [Solved] Cannot read properties of undefined (reading ‘ajax‘); Cannot read property ‘ajax‘ of undefined
- Uniapp: TypeError: Cannot read property ‘apply‘ of undefined (H5 does not report an error, but the real machine runs with an error)
- VUE: Property or method “deleteFun“ is not defined on the instance but referenced during render. [How to Fix]
- Can’t read property ‘push’ of undefined [How to Solve]
- [Solved] Echarts Error: Cannot read property ‘init‘ of undefined
- [Solved] Parcel Package Error: Cannot read property ‘length‘ of undefined
- cesium CLAMP_TO_GROUND Error Cannot read property ‘globe‘ of undefined
- TypeError: res.render is not a function
- [Solved] uview u-sticky Error: Cannot read property ‘bottom‘ of null