After vue uses mock, can mockjs not be refreshed every time the project is restarted?

MockJs.mock (/ PROJECT/, {

)
"data|0-100":[
    {
        "id":"@guid()",
        "projectname":"@ctitle(3, 5)",
        "describe|0-1":"@cparagraph(1)",
        "user|1":"@cname",
        "startdate":"@date()",
        "enddate":"@date()",
        "fileList": [
            {
                "name": "@ctitle(3, 10).word", 
                "url": "@url"
            }
        ]
    }
]

})
I think that after the project starts, the simulated data of mockjs will not change, because each time the localhost:9090/PROJECT is added, deleted, changed or queried, this operation will trigger to refresh the data, resulting in different simulated data each time.

add:

this.axios({
              method:"post",
              url:url,
              data:data
 }).then().catch()

modify:

this.axios({
              method:"put",
              url:url+id,
              data:data
})

.

Mar.28,2021

No. Mock generates data randomly every time the API is called. If you want to save the modified data, do not use mock, to find a place to save the data.


mock.js is randomly generated. Your problem is actually very easy to solve. It is recommended to take a look at this: how to use https://api-v5.segmentfault.com/question/MOCK data efficiently and quickly under .

Menu