在我的角度应用程序中,我正在使用这种处理方法
myMethod(){
...
setTimeout(() => {
this.router.navigate(['mucomponent']);
});
}
Run Code Online (Sandbox Code Playgroud)
正如我被告知的:setTimeout
没有延迟(0)似乎等待下一个蜱虫完成所有治疗后开始我的治疗。这是近期的计划。
因为我需要这种行为
是否有任何干净的替代方法可以用typescript或rxjs做同样的事情来做得更好?
建议?
我在我的 Node js 应用程序中使用sequelize。所有模型都在名为的单独文件中定义,例如,user.js
等message.js
。我还有index.js
自动生成的文件,这是其中的一个片段,您可能会认出它:
if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
sequelize = new Sequelize(config.database, config.username, config.password, config);
}
fs
.readdirSync(__dirname)
.filter(file => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
})
.forEach(file => {
const model = sequelize['import'](path.join(__dirname, file));
db[model.name] = model;
});
Object.keys(db).forEach(modelName => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});
db.sequelize = sequelize;
db.Sequelize = Sequelize;
Run Code Online (Sandbox Code Playgroud)
所以我在这里查看sequelize的关联手册。我无法弄清楚的是,在我的情况下,这会去哪里,因为我使用的是自动生成的index.js
文件,该文件收集所有models
. …
我选择了在移动视图中超出屏幕的下拉菜单。我正在使用引导类form-control
。我的代码如下
<select name="service" formControlName="service" class="form-control shadow-none" style="width:100%">
<option value="Select" selected>Select</option>
<option value="Sedan" selected>Sedan</option>
<option value="SUV" selected>SUV</option>
<option value="Mini" selected>Mini</option>
</select>
Run Code Online (Sandbox Code Playgroud)
任何形式的帮助将不胜感激...
我遇到了一个非常令人沮丧的问题,我无法弄清楚发生了什么。我有一个简单的上下文,如下所示:
import React, { useState, createContext } from "react";
export const AppStateContext = createContext();
const AppStateContextProvider = props => {
const [appState, setAppState] = useState({
cartOpen: false
});
return <AppStateContext.Provider value={{ appState, setAppState }}>{props.children}</AppStateContext.Provider>;
};
export default AppStateContextProvider;
Run Code Online (Sandbox Code Playgroud)
我还将我的应用程序包装在提供程序中:
import React from "react";
import ReactDOM from "react-dom";
import App from "./components/App";
import CssBaseline from "@material-ui/core/CssBaseline";
import { createMuiTheme, ThemeProvider } from "@material-ui/core/styles";
import { deepPurple, amber } from "@material-ui/core/colors";
import AppStateContextProvider from "./contexts/AppStateContext";
const theme = createMuiTheme({
palette: {
type: …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的角度项目中动态设置谷歌地图键。
通常我们在 Angular 项目的 index.html 文件中设置该 API 密钥。现在我想动态更改该键。我将通过一些 API 获取该密钥,问题是如何在我的 index.html 中设置它。任何帮助将不胜感激。
索引.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Angular App</title>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=GOOGLE_API_KEY&libraries=places,drawing&callback=initMap"></script>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<link rel="icon" type="image/x-icon" href="web_images/title_image.png">
</head>
</html>
Run Code Online (Sandbox Code Playgroud) 我有一个mat-list
迭代数据并显示我的要求是以水平方式对齐列表的方法。这可以通过使用简单的材料轻松实现,<ul>
但我正在使用材料并希望利用mat-list
它的功能。由于材质控件带有 CSS,如果我们想更改现有的外观和感觉,我们需要在基本 css 文件中更改它。我不想更改主mat-list-item
css 文件,因为它在项目中的很多地方。我只是想mat-list-item
水平对齐。
<mat-list>
<mat-list-item *ngFor="let privlege of userprivilege"> {{privlege}} </mat-list-item>
</mat-list>
.mat-list-item {
float: right;
display: list-item;
}
Run Code Online (Sandbox Code Playgroud)
我是有角材料的新手,如果有人能提出一种实现它的好方法,我将不胜感激。我在其他地方找不到这样做的方法。
我正在div
使用以下代码检查内容的垂直溢出JS
:
if ($("#col1").prop('scrollHeight') > $("#col1").outerHeight() ) {
alert("this element is overflowing !!");
}
else {
alert("this element is not overflowing!!");
}
Run Code Online (Sandbox Code Playgroud)
但是如何删除溢出的内容并将其转移到另一个内容呢div
?
这是小提琴:https://jsfiddle.net/appsoln/fnecb7mL/6/
if ($("#col1").prop('scrollHeight') > $("#col1").outerHeight() ) {
alert("this element is overflowing !!");
}
else {
alert("this element is not overflowing!!");
}
Run Code Online (Sandbox Code Playgroud)
if ($("#div1").prop('scrollHeight') > $("#div1").outerHeight()) {
alert("this element is overflowing !!");
} else {
alert("this element is not overflowing!!");
}
Run Code Online (Sandbox Code Playgroud)
#main {
background-color: blue;
padding: 15px;
}
#div1 {
padding: 20px; …
Run Code Online (Sandbox Code Playgroud)我正在尝试使用 get 方法从 mongodb 获取用户数据,但它不断给我错误,user.findOne
不是函数用户令牌和 id 成功获取但findOne
不起作用,我对用户模式使用了静态方法。请在这方面帮助我。谢谢。
这是代码:
//userController.js
Router.get("/user",(req,res,next)=>{
var token=req.header("x-auth");
console.log("token3: "+token);
console.log(User);
User.findUserByToken(token).then((then)=>{
if(!User){
Promise.reject();
}else{
req.user=user;
req.token=token;
next();
}
}).catch((error)=>{
res.status(401).send();
});
},(req,res)=>{
res.send(req.user).then(()=>{
}).catch(()=>{
});
})
//user.js
const Schema=mongoose.Schema;
const userSchema=new Schema({
name:{
type: String,
trim: true,
required: true,
minlength: 6
},
email:{
type:String,
unique:true,
trim: true,
required: true,
minlength: 6
},
password:{
type: String,
trim: true,
required: true,
minlength: 8
},
tokens:[
{
access:{
type:String,
required:true
},
token:{
type:String,
required:true …
Run Code Online (Sandbox Code Playgroud) angular ×3
css ×3
javascript ×3
html ×2
node.js ×2
bootstrap-4 ×1
ecmascript-6 ×1
google-maps ×1
jquery ×1
mongodb ×1
react-hooks ×1
reactjs ×1
rxjs ×1
sequelize.js ×1
typescript ×1
undefined ×1