Sometimes when typing JS code, you will often encounter such errors:
This is due to careless typing of code, resulting in grammatical format errors.
If the object literal is used to define the object, the relationship between the attribute name and the attribute value:
<script>
var province = [{
id: 1002,
name: 'Heibei',
city: [{
id: 1,
name= 'Shijiazhuang' // use object literals to define objects with attribute names separated from attribute values by:.
},
{
id: 2,
name: 'Handan'
}
]
}];
</script>
Grammar norms are very important. Try not to make mistakes that can be avoided.
Read More:
- vue Error: Uncaught SyntaxError: Invalid shorthand property initializer
- JS bug Log Uncaught TypeError: Cannot read property ‘previoustSibling‘ of null
- [Solved] Turf.js error: uncaught (in promise) error: the solution of invalid unit
- [Solved] echarts Draw Errror: echarts-d9fd185e.js:31447 Uncaught (in promise) Error: Initialize failed: invalid dom.
- [vite] Failed to parse source for import analysis because the content contains invalid JS syntax.
- [Solved] JS Error: Uncaught TypeError: Cannot set properties of null (setting ‘innerHTML‘)
- [Solved] electron Error: Uncaught TypeError: Cannot read property ‘BrowserWindow‘ of undefined
- Method to solve uncaught typeerror: cannot set property ‘onclick’ of null error
- [Solved] JS Error: cannot set property xxx of undefined
- [Solved] JS Error: Uncaught SyntaxError: Illegal return statement
- [Solved] Binding onclick event in JS: for loop: error uncaught typeerror: cannot set properties of undefined (setting ‘classname’)
- [Solved] Uni.createintersectionobserver Error: Uncaught TypeError: Cannot read property ‘bottom’ of null
- [Solved] Syntax Error: TypeError: Cannot read property ‘parseComponent‘ of undefined
- [Solved] Syntax Error: TypeError: Cannot set property ‘parent‘ of undefined
- [Solved] Syntax Error: TypeError: Cannot read property ‘parseComponent‘ of undefined
- [Solved] vue.esm.js?efeb:591 [Vue warn]: Error in event handler for “click“: “TypeError: Cannot read property
- [Solved] Uncaught SyntaxError: Invalid Unicode escape sequence
- JS async await Error: Uncaught SyntaxError: await is only valid in async functions and the top level bodies of modules
- [Solved] vue-roter 4 Error: Error: Invalid route component/Uncaught (in promise) Error: Invalid route component
- How to Test whether the property value of each property in the object is not empty