我正在使用nodeJs,handlebars和expressJs框架开发一个项目.我使用i18n-express模块添加更改语言功能.当我们要更改语言时,此模块在url的末尾添加查询字符串.现在的问题是,当我将一个页面移动到另一个页面时,查询字符串被删除并失去他的状态.那我怎样才能保持语言状态?如果用户选择法语,则所有页面均以法语打开.这就是我要的.
码:
var i18n = require("i18n-express");
app.use(i18n({
translationsPath: path.join(__dirname, 'lang'), // <--- use here. Specify translations files path.
siteLangs: ["ar","en","cn","fr","ge","he","hu","it","ja","ko","es","ru"],
cookieLangName : 'ulang',
textsVarName: 'translation'
}));
Run Code Online (Sandbox Code Playgroud)
链接以更改语言
<a href="#!" id="{{icon}}" onclick=" return changeLanguage(this)"></a>
Run Code Online (Sandbox Code Playgroud)
Onclick功能可以改变语言
function changeLanguage(event){
$('#languages img').attr('src','/images/flag-icons/'+event.id+'.png');
var url = window.location.href;
url = url.split("?")[0];
url += '?clang='+event.id;
window.location.href = url;
localStorage.setItem("clang", '?clang='+event.id); //event.id returns locale name such as en, ar, sp, fr etc.
//console.log(url);
}
Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用Firebase,但auth/operation-not-supported-in-this-environment在使用Google凭据登录时出现此错误.
.hbs文件代码
<span class="google-bg session-icon">
<a href="#!" id="google" onclick=" return loginWithGoogle(this)">
<i class="ti-google"></i>
</a>
</span>
Run Code Online (Sandbox Code Playgroud)
脚本代码
function loginWithGoogle(event){
$.ajax({
url: "/session/google/login",
type: "POST"
})
.done(function (data) {
error= JSON.stringify(data);
console.log(error);
M.toast({html: error})
});
}
Run Code Online (Sandbox Code Playgroud)
快递代码
router.post('/session/google/login',function (req, res, next){
//console.log('get resqust');
firebase.auth().signInWithRedirect(googleAuthProvider).then(function(result){
console.log(result);
}, function(error){
console.log(error.code);
res.json({
data: error.code
})
});
})
Run Code Online (Sandbox Code Playgroud)
当我点击Google图标然后调用loginWithGoogle函数并获得路由器路径/session/google/login后执行快速代码并生成错误.我想知道解决这个问题,可能出现什么问题?
谢谢!!!
更新(16-10-18)
使用Gmail帐户成功登录后,请拨打信息中心路线.
router.get('/dashboard', function(req, res, next) {
console.log(firebase.auth().currentUser);
if(firebase.auth().currentUser != null){
res.render('dashboard', {
title: 'App'
});
}else {
req.session.error = …Run Code Online (Sandbox Code Playgroud) 我正在做一个 React 项目,当我将 webpack 4.44.2 更新到 5.4.0 时,我收到以下消息:
[DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
(Use `node --trace-deprecation ...` to show where the warning was created)
Run Code Online (Sandbox Code Playgroud)
我搜索了很多,但没有得到确切的答案。那么我该如何解决呢?
我正在开发一个 Laravel Reactjs 项目,当我运行命令时,npm run dev编译停留在 95% 并给出以下错误。我检查了整个项目,没有使用区分大小写的名称进行文件调用,所有图像都使用小写字母进行调用。
Error: Prevent writing to file that only differs in casing or query string from already written file.
This will lead to a race-condition and corrupted files on case-insensitive file systems.
/media/public/images/user-4.jpg
/media/public/images/user-4.jpg
Run Code Online (Sandbox Code Playgroud)
反应:17.0.1
网络包:5.21.2
节点:14.15.2
我正在使用 Vue.js 模板和注册页面,我需要在用户注册时比较密码,因此,我添加了自定义验证规则,如下面的代码:
<v-text-field
label="Password"
v-model="password"
:rules="passwordRules"
type="password"
required
></v-text-field>
<v-text-field
label="Confirm Password"
v-model="confirmPassword"
:rules="[confirmPasswordRules,passwordConfirmationRule]"
type="password"
required
></v-text-field>
Run Code Online (Sandbox Code Playgroud)
脚本:
data() {
return {
password: "",
confirmPassword: "",
passwordRules: [v => !!v || "Password is required"],
confirmPasswordRules: [v => !!v || "Password is required"],
};
},
Run Code Online (Sandbox Code Playgroud)
在计算中比较密码方法:
computed: {
passwordConfirmationRule() {
return () => (this.password === this.confirmPassword) || 'Password must match'
},
}
Run Code Online (Sandbox Code Playgroud)
我使用计算方法确认密码它工作正常并完美地比较密码但它在控制台中显示错误[Vuetify] Rules should return a string or boolean, received 'object' instead 所以我该如何解决这个问题?
我正在研究 vueJs 模板,我需要以三种格式导出表数据,即 .pdf、.csv、.xls 我尝试过这个问题,但它的 show Utils 未定义。那么我怎样才能实现我想要的
我正在处理 Vue.js 模板,我需要创建一个高达 3 级的菜单。如果我使用 v-model 执行主动停用功能,那么它工作正常,但在第 1 级,而不是在第 2 级。
多姆:
<template v-for="item of category">
<template v-if="item.items!= null">
<v-list-group :key="item.title" no-action v-model="item.active">
<template v-slot:activator>
<i class="mr-2" :class="item.action"></i>
<span>{{ item.title }}</span>
</template>
<div>
<template v-for="child in item.items">
<template v-if="child.subitems !== null">
<v-list-group sub-group no-action :key="child.id" prepend-icon="m"
v-model="child.subactive">
<template v-slot:activator>
<v-list-item-title v-text="child.title">
<i class="mr-2" :class="child.action"></i>
</v-list-item-title>
</template>
<template v-for="(subchild) in child.subitems">
<v-list-item :key="subchild.id"
:to="subchild.path">
<v-list-item-title v-text="subchild.title"></v-list-item-title>
</v-list-item>
</template>
</v-list-group>
</template>
</tempalte>
</div>
</v-list-group>
</template>
</template>
Run Code Online (Sandbox Code Playgroud)
数据:
export const category = [ …Run Code Online (Sandbox Code Playgroud) 我最近开始使用 mongoDB,并一次又一次地遇到这个问题。我想我错过了一些东西,但不知道问题出在哪里。我正在开发最新的 mongo db 版本 4.0.1。
iron@iron-System-Product-Name:/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/codesnippets$ sudo mongod --dbpath db
2018-08-24T09:30:26.351+0530 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] MongoDB starting : pid=5994 port=27017 dbpath=db 64-bit host=iron-System-Product-Name
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] db version v4.0.1
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] git version: 54f1582fc6eb01de4d4c42f26fc133e623f065fb
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] allocator: tcmalloc
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] modules: none
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] build …Run Code Online (Sandbox Code Playgroud) 我正在研究 VueJs 模板,我有一个 Vuetify 数据表,我创建了一个表标题的选择列表。
在选择列表的基础上,如果任何标题未选中,我想显示和隐藏表格的列,那么它将从表格中隐藏,就像选中然后将出现在表格中一样。
选择列表:
<v-select
v-model="value"
:items="headers"
label="Select Item"
multiple
>
<template v-slot:selection="{ item, index }">
<v-chip v-if="index === 0">
<span>{{ item.text }}</span>
</v-chip>
<span
v-if="index === 1"
class="grey--text caption"
>(+{{ value.length - 1 }} others)</span>
</template>
</v-select>
Run Code Online (Sandbox Code Playgroud)
如果我单击位于第一个选项卡内容中的按钮,那么我想移至下一个选项卡。我怎样才能做到这一点??
标签:
<v-tabs
color="cyan"
dark
slider-color="yellow"
>
<v-tab ripple>
Item 1
</v-tab>
<v-tab ripple>
Item 2
</v-tab>
<v-tab-item>
<v-card flat>
<v-btn @click="changeTab()">
</v-card>
</v-tab-item>
<v-tab-item>
<v-card flat>
<v-card-text>Contents for Item 2 go here</v-card-text>
</v-card>
</v-tab-item>
</v-tabs>
Run Code Online (Sandbox Code Playgroud)
方法:
changeTab(){
console.log('hello')
}
Run Code Online (Sandbox Code Playgroud) 我正在使用react-bootstrap开发一个react项目,并在单击下拉菜单时遇到此警告。
Popper:CSS“边距”样式不能用于在 Popper 与其参考元素或边界之间应用填充。要复制边距,请使用offset修饰符以及和修饰符padding中的选项。preventOverflowflip
<Dropdown alignRight className="dropdown m-0">
<Dropdown.Toggle as={CustomToggle} />
<Dropdown.Menu style={{ margin: 0 }}>
<Dropdown.Item >edit</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
嗨,我正在处理 Vue.js 模板,但我遇到了需要使用循环语句显示动态 v-dialog 的问题,但现在它显示了所有内容。
多姆:
<template v-for="item of faq">
<div :key="item.category">
<h4>{{ item.heading }}</h4>
<div v-for="subitems of item.content" :key="subitems.qus">
<v-dialog
v-model="dialog"
width="500"
>
<template v-slot:activator="{on}">
<a href="#" v-on="on">{{subitems.qus}}</a>
</template>
<v-card>
<v-card-title
class="headline grey lighten-2"
primary-title
>
Privacy Policy
</v-card-title>
<v-card-text>
{{ subitems.ans }}
</v-card-text>
<v-divider></v-divider>
</v-card>
</v-dialog>
</div>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
脚本:
export default {
data: () => ({
faq,
dialog:false,
}),
}
Run Code Online (Sandbox Code Playgroud)
我不明白我怎么能做到这一点。如果我单击一个按钮,则它会显示所有内容。
javascript ×8
vue.js ×6
vuetify.js ×5
reactjs ×3
express ×2
node.js ×2
webpack ×2
webpack-5 ×2
export ×1
firebase ×1
laravel-8 ×1
mongodb ×1
popper.js ×1
validation ×1
vuejs2 ×1