Read static file with vuejs stand-alone

Asked

Viewed 277 times

0

I have an application created with the default VUE-CLI configuration, and I need to read a json file from the public folder.

After compiling the application with npm run build, the user should be able to exchange this json file and the application be this new json. That is why I have used the public folder, because the files in this folder are not compiled by webpack.

But as the application runs stand-alone, without server, I cannot read this json.

If require or Axios use, I have Cors problem or lack of permission. What is the correct way to load a json file in an offline application?

Sorry for the lack of formatting, I’m from the mobile. Thank you.

  • the ideal was for you to climb a server with node/express referencing your Vue build, then yes you will be able to read the file json with the axios

  • Yes, I did that and it worked even for rs. The problem is that this page displays inside a Windows application, it opens inside a webview as a static file, so I don’t have that possibility. =(

  • Complementing the response, the application generates a json and then opens the webview page, which displays the elements of this json.

  • so I don’t quite understand it, inside a webview ( so it’s a mobile app ? ). Can you just work offline? Because otherwise you can upload a server with this json file and query via api, or better via ajax or Axios request

  • you have tried using jquery $.getJSON?

  • It’s a Windows application, done in wpf. I have a window with a built-in Chromium webview. It’s like a mobile webview. It’s the same effect as you go in the build folder and double-click to open the.html index in the browser. I’ll try jquery coming home.

  • Why don’t you edit your question and add more relevant tags to your question (like [tag:wpf] or [tag:webview])? So it may be that someone who understands the subject finds your question.

  • It is because the question has nothing to do with wpf, wpf itself generates Json, but the problem is with Node and Vue itself.

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.