我制作了一个从 Contentful 中提取数据的页面。数据正确提取,但使用方法中的功能的按钮不起作用。变量的实时更新(例如,使用v-model)也不起作用。
我在控制台中看到此错误:
我认为这个错误是问题所在。有谁知道出了什么问题?我不知道如何解决它:(
我的 contentful.js:
const contentful = require('contentful')
const client = contentful.createClient({
space: process.env.CONTENTFUL_ENV_SPACE_ID,
accessToken: process.env.CONTENTFUL_ENV_ACCESS_TOKEN
})
module.exports = client
Run Code Online (Sandbox Code Playgroud)
拉取数据的代码:
export default {
layout: "landing_page",
asyncData() {
return client
.getEntries({
content_type: "landingPage"
})
.then(entries => {
return { contentfulData: entries.items[0].fields };
});
},
computed: {
styles() {
return landingPageCss;
}
},
components: {
priceBox,
contact,
home,
aboutUs,
footerDiv
}
};
Run Code Online (Sandbox Code Playgroud) 我正在研究 VueCLI。我创建了包含输入规则的 .js 文件:
import Vue from 'vue'
export const $t = (sign) => Vue.prototype.$t(sign)
function checkMail(email) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ // eslint-disable-line no-eval
return re.test(String(email).toLowerCase())
}
const rules = {
gdprRequired: (v) => !!v || $t('registerPage.gdprNotChecked'),
emailRules: [(v) => checkMail(v) || $t('registerPage.wrongMail')],
}
export default rules
Run Code Online (Sandbox Code Playgroud)
我想在外部js文件中声明规则,然后在其他vue文件中导入它。当我正确执行此规则检查值时,但它不显示翻译的错误消息。我试过export const $t = (sign) => Vue.prototype.$t(sign),bcs 类似的代码适用于 nuxt,但在这里,在 VueCLI 中我得到了错误:
vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in beforeMount hook: "ReferenceError: $t is not defined"
found in
---> <VTextField>
<VForm>
<Register>
<VMain> …Run Code Online (Sandbox Code Playgroud) 是否有可能在 Nuxt 应用程序中部署完整的 wordpress 应用程序?我的意思是我想知道foo.com我的应用程序的地址,然后foo.com/bar是 wordpress 应用程序。有没有办法做到这一点?nuxt router 能不能处理这个?
Wordpress API 和 iframe 不是我要寻找的答案。正如我所说,我想在我的 Nuxt 应用程序的特定地址上部署整个 wordpress。
vue.js ×3
javascript ×2
nuxt.js ×2
axios ×1
contentful ×1
node.js ×1
vue-cli ×1
vue-i18n ×1
vue-router ×1
vuejs2 ×1
wordpress ×1