Why does the data in vue need to be initialized?

for example, I wrote:

: {
           data:() => { return {arr: []} }
        }
:  {
           data:() => { return {arr: null} }
        }
createdthis.arr


this.arr
(:arr)
Apr.08,2021

maybe you have a component that binds arr, and handles null, by reporting an error. If it's just Vue, I don't repeat the problem

< hr >

on August 13, 2018, 14-26-12-42, it was found that the problem was supplemented

.

then let me add one more point.

clipboard.png
according to the lifecycle of the vue instance, Created is prior to template rendering, but asynchronous operations do not block the lifecycle.

that is, although the requested data is in Created, the data has not been obtained before the instance template is rendered.
then the arr in the template will report an error when it is still used by null,.

there is no way to block the life cycle of an instance in Vue. If you use Vue-router, you can use the hook of beforeRouterEnter to get the data, and then jump to


what's wrong with misreporting?


This array is used in the

template, and if the value is changed to null, an error will be reported.
for example, if you write the following code in native JS, native JS will also report an error

  https://cn.vuejs.org/v2/guide.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3897b-2b673.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3897b-2b673.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?