我有一个带有多个输入的html表单,如下所示:
<input name="hello[]" type="text" />
<input name="hello[]" type="text" />
<input name="hello[]" type="text" />
Run Code Online (Sandbox Code Playgroud)
在PHP中,你将它作为一个数组得到,但它在使用Flask的Python中是一样的吗?
我试过这个:
hello = request.form['hello']
print(hello)
Run Code Online (Sandbox Code Playgroud)
在Flask中,但是没有用,我收到了"400次错误请求":
Bad Request
The browser (or proxy) sent a request that this server could not understand.
Run Code Online (Sandbox Code Playgroud)
我如何在Flask中做到这一点?
我在Angular2中有一个组件,它在我的服务translate.service.ts中更改了一个"lang"类变量.在另一个组件中,我正在使用init上的转换获取dict.如果第一个组件稍后更改了服务语言,我想自动重新获取第二个组件中的dict.我怎么做?
第一部分:
setLang(lang) {
this._translateService.setLang(lang);
}
Run Code Online (Sandbox Code Playgroud)
服务:
dict = { "en": {}};
lang = "en";
setLang(lang) {
this.lang = lang;
}
getLang() {
return this.dict;
}
Run Code Online (Sandbox Code Playgroud)
第二部分:
ngOnInit() {
this.dict = this._translateService.getDict();
}
Run Code Online (Sandbox Code Playgroud) 我想知道如何为Angular 2项目添加更少的编译.因为每个组件都有自己的.css文件(现在它将是.less文件)我不知道如何将文件编译为css ...
我也搜索了这个问题而没有找到解决问题的办法.
编辑为了使我的问题更清楚:我希望每个组件都有一个.less,就像它在Angular 2中的.css文件一样默认.我只想要每个.less都要预编译,因为Angular包括在Angular处理组件之后,css作为内联脚本,我想我之间需要一些较少的预处理脚本,它是否存在?
对于整个项目,我宁愿没有一个大的.less文件包含手册,这当然是一个可能的解决方案.这个解决方案似乎不符合Angular环境,但......
我在安装React-native时遇到错误,我试图搜索答案,但我找不到答案.
运行"react-native init meet"时出现此错误:
This will walk you through creating a new React Native project in /Users/alfred/React/meet
Installing react-native package from npm...
Setting up new React Native app in /Users/alfred/React/meet
module.js:338
throw err;
^
Error: Cannot find module './src/init'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/alfred/React/meet/node_modules/react-native/node_modules/yeoman-generator/node_modules/download/node_modules/vinyl-fs/node_modules/gulp-sourcemaps/index.js:4:9)
at Module._compile (module.js:434:26)
at Module._extensions..js (module.js:452:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/alfred/React/meet/node_modules/react-native/node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
Run Code Online (Sandbox Code Playgroud)
我真的没有弄错...
我注意到Angular 2中有一个名为CurrencyPipe的管道,它会从一个数字中过滤掉一些小数.这也增加了ISO货币指标,即"美元"或任何其他本地货币.
我的问题是输出显示如下:
USD123
Run Code Online (Sandbox Code Playgroud)
没有美元和123之间的空间,这真的是首选行为吗?我是否必须为此编写自己的管道,或者我可以做些什么来添加空间?
这是一些代码:
<span>{{ product.price | currency:'USD' }}</span>
Run Code Online (Sandbox Code Playgroud) 我在我的反应本机项目中使用navigator.geolocation.watchPosition在用户移动时在地图上绘制路径.我注意到此功能的返回频率非常低.当我使用iOS模拟器和gps模拟器中的"高速公路驱动"模式进行测试时,我教过它至少是频率.现在,当我用"城市跑"测试时,我可以看到位置的返回频率不依赖于某个时间间隔,而是取决于距离...该功能每100米返回一次位置,无论如何这个职位需要多长时间才能改变这一点.
为什么会这样?这是预期的行为吗?我不知道它是否与iOS模拟器或我的代码有关,但我真的希望这个位置更精确,我希望它尽可能频繁地返回.
componentDidMount() {
const { region } = this.state;
navigator.geolocation.getCurrentPosition(
(position) => {
this.setState({position});
},
(error) => alert(JSON.stringify(error)),
{enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
);
this.watchID = navigator.geolocation.watchPosition((lastPosition) => {
var { distanceTotal, record } = this.state;
this.setState({lastPosition});
if(record) {
var newLatLng = {latitude:lastPosition.coords.latitude, longitude: lastPosition.coords.longitude};
this.setState({ track: this.state.track.concat([newLatLng]) });
this.setState({ distanceTotal: (distanceTotal + this.calcDistance(newLatLng)) });
this.setState({ prevLatLng: newLatLng });
}
},
(error) => alert(JSON.stringify(error)),
{enableHighAccuracy: true, timeout: 20000, maximumAge: 0});
}
Run Code Online (Sandbox Code Playgroud) 我想从文件系统中的另一个地方运行makefile.如何传递makefile的位置?
如果我站在"/"并且我想运行一个抵制在"/ dir/dir2/dir3/makefile"中的makefile,我该如何将它添加到make命令中?
我试过了:
make --file=dir/dir2/dir3/makefile
Run Code Online (Sandbox Code Playgroud)
但它没有奏效.
我想使用Angular 2实现拖放.我有一些项目:
<div class="item"></div>
Run Code Online (Sandbox Code Playgroud)
我希望能够在容器中拖放:
<div class="container"></div>
Run Code Online (Sandbox Code Playgroud)
我在Angular 2中找不到任何好的信息来源.我找到了这个文件:https://github.com/AngularClass/angular2-examples/blob/master/rx-draggable/directives/draggable.ts我尝试但我无法让它工作,我也不完全确定它应该如何工作.
我该如何实现它?
我在Golang有一个包含几个模块的项目.由于以下场景,我遇到循环导入问题:
模块游戏包含具有当前游戏状态的结构.另一个模块(Modifier)正在做一些游戏特定的东西和计算,因此修改了游戏状态.因此,Modifier将需要struct Game,但不需要来自Game的任何方法.从Game中调用修饰符,这里我们有循环导入.
游戏启动修改器
修饰符需要Game结构
在我看来,这是一个常见的场景,所以我想知道我应该如何以最好的方式解决它.我的解决方案是创建第三个模块"Structs",它只包含整个应用程序的所有结构.这是一个好的解决方案吗?
我正在尝试在我的React项目中使用CSS模块。问题的第一部分是,如果我编写嵌套的css类(使用sass),我不知道是否可以访问内部的类,因为它们似乎也被编译成唯一的类名。一些代码:
<div className={this.state.visible ? styles.header+" menu-visible" : styles.header}>
<div className="menu">
<a className="link">title</a>
</div>
</div>
.header {
&.menu-visible {
.menu {
display:block;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个包装类,有时它是“菜单可见的”,它会改变所有子级的属性,在React中像这样做是不好的做法吗?
如果菜单可见,则.header中有多个类可以更改,因此仅更改包装类将很方便,我可以以某种方式引用这些子类吗?这样剩下的嵌套在scss中吗?
编辑
我能想到的一种解决方案是将className =“ menu”替换为className = {styles.header.menu},但这似乎行不通。问题是,如果它的父级具有菜单可见的类,我希望.menu更改其属性。
angular ×4
css-modules ×1
flask ×1
geolocation ×1
go ×1
gulp ×1
html ×1
less ×1
makefile ×1
python ×1
react-native ×1
reactjs ×1