Forkify (my github link) is a tutorial project I'm working on. To build the dist files, I use parcel
.
When I use yarn start
for local deployment, it works correctly, but when I deploy to Netlify and use yarn build
, it does not work correctly. The all js code I wrote does not work.
What can I do to fix it?
package.json
:
"scripts": {
"start": "parcel index.html",
"build": "parcel build index.html"}
As others have pointed out, you do indeed have a bug (or a few) in your code.
In src/js/model.js
, your init
function assumes that bookmarks are already available in local storage, so a simple work around is to push an empty array if the bookmarks key doesn't exist in local storage.
export const init = function () {
state.bookmarks.push(...JSON.parse(localStorage.getItem("bookmarks") || "[]"));
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.