英文:
Github error 404 on console with payload js
问题
我刚刚部署了我的Nuxt应用程序,出现了一些与payload js相关的错误,我不知道这是什么错误。
以下是我的文件目录
我发现payload.js
文件中出现错误:...1673214939/<page-name>/payload.js
所有的payload.js
文件都包含相同的代码:
__NUXT_JSONP__("/albums", {data:[{}],fetch:{},mutations:[]});
在本地主机上运行正常,但在GitHub上,导航栏中的图标不显示,因为出现了错误。
这是我的nuxt.config.js和package.json文件:
nuxt.config.js
:
export default {
head: {
title: 'Florida',
htmlAttrs: {
lang: 'en',
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' },
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
target: 'static',
router: {
base: '/FloridaGifts/'
},
css: ["./assets/main.scss"],
plugins: [
{
src: './plugins/vue-icons.js',
mode: 'client'
},
],
components: true,
buildModules: [
'@nuxtjs/eslint-module',
'@nuxtjs/dotenv'
],
modules: [
'bootstrap-vue/nuxt',
'@nuxtjs/axios',
[
'@nuxtjs/firebase',
{
config: {
apiKey: process.env.API_KEY,
authDomain: process.env.AUTH_DOMAIN,
databaseURL: process.env.DATABASE_URL,
projectId: process.env.PROJECT_ID,
storageBucket: process.env.STORAGE_BUCKET,
messagingSenderId: process.env.MESSAGING_SENDER_ID,
appId: process.env.APP_ID,
measurementId: process.env.MEASUREMENT_ID
},
services: {
auth: {
initialize: {
onAuthStateChangedAction: 'onAuthStateChangedAction',
}
},
database: true,
storage: true
}
}
]
],
axios: {
baseURL: '/',
},
build: {},
}
package.json
:
{
"name": "client",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"deploy": "push-dir --dir=dist --branch=gh-pages --cleanup",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint:prettier": "prettier --check .",
"lint": "npm run lint:js && npm run lint:prettier",
"lintfix": "prettier --write --list-different . && npm run lint:js -- --fix",
"test": "jest"
},
"dependencies": {
"@nuxtjs/axios": "^5.13.6",
"@nuxtjs/dotenv": "^1.4.1",
"@nuxtjs/firebase": "^8.2.2",
"bootstrap": "^4.6.2",
"bootstrap-vue": "^2.22.0",
"core-js": "^3.25.3",
"hooper": "^0.3.4",
"nuxt": "^2.15.8",
"vue": "^2.7.10",
"vue-server-renderer": "^2.7.10",
"vue-template-compiler": "^2.7.10"
},
"devDependencies": {
"@babel/eslint-parser": "^7.19.1",
"@nuxtjs/eslint-config": "^11.0.0",
"@nuxtjs/eslint-module": "^3.1.0",
"@vue/test-utils": "^1.3.0",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^29.1.2",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.0.4",
"eslint-plugin-nuxt": "^4.0.0",
"eslint-plugin-vue": "^9.5.1",
"jest": "^29.1.2",
"jest-environment-jsdom": "^29.1.2",
"prettier": "^2.7.1",
"push-dir": "^0.4.1",
"sass": "^1.56.1",
"sass-loader": "^10.4.1",
"vue-jest": "^3.0.4",
"webpack": "^4.45.0"
}
}
在部署时,我运行了以下命令:
npm run generate
npm install push-dir --save-dev
npm run generate
npm run deploy
仓库链接:仓库
gh-pages(部署)链接:部署
开发中的警告:
DOM不匹配错误的源代码:
else if (hasConsole_1 && !config.silent) {
console.error("[Vue warn]: " + msg + trace);
}
英文:
I have just deployed my Nuxt app and there are some errors with payload js, I have no idea what error is this.
Here is my file directory
I found that payload.js file
which is in error: ...1673214939/<page-name>/payload.js
and there is in all payload.js
files same code:
__NUXT_JSONP__("/albums", {data:[{}],fetch:{},mutations:[]});
It is working well on localhost but in github, icons in Navbar are not apearing because of errors.
There my nuxt.config.js and package.json files:
nuxt.config.js
:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
export default {
head: {
title: 'Florida',
htmlAttrs: {
lang: 'en',
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' },
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
target: 'static',
router: {
base: '/FloridaGifts/'
},
css: ["./assets/main.scss"],
plugins: [
{
src: './plugins/vue-icons.js',
mode: 'client'
},
],
components: true,
buildModules: [
'@nuxtjs/eslint-module',
'@nuxtjs/dotenv'
],
modules: [
'bootstrap-vue/nuxt',
'@nuxtjs/axios',
[
'@nuxtjs/firebase',
{
config: {
apiKey: process.env.API_KEY,
authDomain: process.env.AUTH_DOMAIN,
databaseURL: process.env.DATABASE_URL,
projectId: process.env.PROJECT_ID,
storageBucket: process.env.STORAGE_BUCKET,
messagingSenderId: process.env.MESSAGING_SENDER_ID,
appId: process.env.APP_ID,
measurementId: process.env.MEASURMENT_ID
},
services: {
auth: {
initialize: {
onAuthStateChangedAction: 'onAuthStateChangedAction',
}
},
database: true,
storage: true
}
}
]
],
axios: {
baseURL: '/',
},
build: {},
}
<!-- end snippet -->
package.json
:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-json -->
{
"name": "client",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"deploy": "push-dir --dir=dist --branch=gh-pages --cleanup",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint:prettier": "prettier --check .",
"lint": "npm run lint:js && npm run lint:prettier",
"lintfix": "prettier --write --list-different . && npm run lint:js -- --fix",
"test": "jest"
},
"dependencies": {
"@nuxtjs/axios": "^5.13.6",
"@nuxtjs/dotenv": "^1.4.1",
"@nuxtjs/firebase": "^8.2.2",
"bootstrap": "^4.6.2",
"bootstrap-vue": "^2.22.0",
"core-js": "^3.25.3",
"hooper": "^0.3.4",
"nuxt": "^2.15.8",
"vue": "^2.7.10",
"vue-server-renderer": "^2.7.10",
"vue-template-compiler": "^2.7.10"
},
"devDependencies": {
"@babel/eslint-parser": "^7.19.1",
"@nuxtjs/eslint-config": "^11.0.0",
"@nuxtjs/eslint-module": "^3.1.0",
"@vue/test-utils": "^1.3.0",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^29.1.2",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.0.4",
"eslint-plugin-nuxt": "^4.0.0",
"eslint-plugin-vue": "^9.5.1",
"jest": "^29.1.2",
"jest-environment-jsdom": "^29.1.2",
"prettier": "^2.7.1",
"push-dir": "^0.4.1",
"sass": "^1.56.1",
"sass-loader": "^10.4.1",
"vue-jest": "^3.0.4",
"webpack": "^4.45.0"
}
}
<!-- end snippet -->
And when I was deploying it, I have run these commands
npm run generate
npm install push-dir --save-dev
npm run generate
npm run deploy
link to repository: repository
link to gh-pages(deploy): deploy
Warnings in dev:
Source of DOM missmatch error:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
else if (hasConsole_1 && !config.silent) {
console.error("[Vue warn]: ".concat(msg).concat(trace));
}
<!-- end snippet -->
答案1
得分: 1
OP按照此处建议解决了问题,使用了client-only
:https://stackoverflow.com/a/67978474/8816585
在使用v-for
时修复一些唯一ID键也有所帮助。
我还推荐此解决方案以实现一种通用的图标使用方式,避免了设置和处理各种怪癖所带来的痛苦。
英文:
OP solved the issue with a client-only
as proposed here: https://stackoverflow.com/a/67978474/8816585
Fixing some unique ID keys while using v-for
also helped.
I also recommend this solution to have a universal way of using icons without all the pain or setting it up and dealing with various quirks.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论