Can you new objects in the data of vue

  data: function () {
    class baseObj{
        constructor(src){
            this.flag=true,
            this.mapvLayer=null,
        //   this.data=null,
            this.total=0,
            this.src=require(src)            
        }
    }      
    return {
      //
    //   history:{
    //       flag:true,
    //       mapvLayer:null,
    //       data:null,
    //       total:0,
    //       src:require("../../../../assets/images/map_people.png")
    //   },
      history:new baseObj("../../../../assets/images/map_people.png"),

reported this wrong: Cannot find module "."
is this all right? later, I wrote that class into a js file alone, and it didn"t seem to work to import it. I asked for a great god

.

Yes, the problem lies in your other code, not here. Here is


you can new object
in the data of vue. Your problem here is that the resource of require is a variable this.src=require (src)


require should only be a static path, not a dynamic variable

.
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-1b39a66-2aef3.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-1b39a66-2aef3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?