运行此代码时,出现错误“错误:属性'pos'必须是向量。” 我必须在某个地方写另一个向量吗?因为我在写向量
grav_force = vector(0,-object.mass*grav_field,0)
Run Code Online (Sandbox Code Playgroud)
这是我的整个代码
GlowScript 2.7 VPython
from visual import *
display(width = 1300, height = 1000)
projectile = sphere(pos = (-5,0,0),
radius = 0.1,
color = color.red,
make_trail = True)
projectile.speed = 3.2 # Initial speed.
projectile.angle = 75*3.141459/180 # Initial angle, from the +x-axis.
projectile.velocity = vector(projectile.speed*cos(projectile.angle),
projectile.speed*sin(projectile.angle),
0)
projectile.mass = 1.0
grav_field = 1.0
dt = 0.01
time = 0
while (projectile.pos.y >=0):
rate(100)
# Calculate the force.
grav_force = vector(0,-projectile.mass*grav_field,0)
force = grav_force
# …Run Code Online (Sandbox Code Playgroud) 我有个问题。我用HTML中的按钮制作了一个循环。因此,现在我希望他们在按下按钮时更改颜色。但是我有一个问题,就是它们都会改变颜色。但是我只想更改所按下按钮的颜色。
的HTML
<ion-item *ngFor="let friend of friendsList">
<ion-avatar item-start>
<img src={{friend.img}}>
</ion-avatar>
<button ion-button color="rank" class="avat"> </button>
<h2>{{friend.name}}</h2>
<p>{{friend.status}}</p>
<button (click)="toggleNamedColor()" ion-button round color="rank" [color]="ionicNamedColor" item-end>+Add</button>
</ion-item>
</ion-list>
Run Code Online (Sandbox Code Playgroud)
TS
public ionicNamedColor: string = 'rank';
public toggleNamedColor(): void {
if(this.ionicNamedColor === 'rank') {
this.ionicNamedColor = 'primary'
} else {
this.ionicNamedColor = 'rank'
}
}
Run Code Online (Sandbox Code Playgroud) 我想在这两个文本输入下创建一个按钮.我刚刚超过了文档中的代码.但我得到这个错误:
该
div函数需要2个参数,但它有5个参数.
我怎么解决这个问题?
-- VIEW
view : Model -> Html Msg
view model =
div []
[ input [ placeholder "Team 1", style "width" "300px", style "height" "30px", style "font-size" "25px", value model.content ] []
, input [ placeholder "Strength", style "width" "300px", style "height" "30px", style "font-size" "25px", value model.content ] []
]
div []
[ button [ style "color" "white", style "height" "60px", style "font-size" "30px", style "margin-right" "70px"]
]
Run Code Online (Sandbox Code Playgroud) 我尝试实现更多的html元素,如title(h1)或img src.我在我的代码中采用了h1方法,但遗憾的是没有工作.按钮和输入,我在文档中找到但我并没有真正得到(也来自其他教程)如何实现其他元素.
-- VIEW
view : Model -> Html Msg
view model =
div []
[ h1 [] [ text "todos" ]
]
[ div[] [ input [ placeholder " Team 1", style "width" "300px", style "height" "30px", style "font-size" "25px", style "color" "#488aff", value model.content] []
, input [ placeholder " Strength", style "width" "300px", style "height" "30px", style "font-size" "25px", style "color" "#32db64", value model.content ] []
]
, div []
[ button [ style "background-color" "#66cc81", style …Run Code Online (Sandbox Code Playgroud) 我想对我的列表进行排序,但是当我使用关键字.sort时出现错误:
这不是记录,因此没有要访问的字段!
106 | {model | teams = List.sort.map(\ p - > {p | activated = True})model.teams,activatedOutput = True} ^^^^^^^^^这个
sort值是:Run Code Online (Sandbox Code Playgroud)List comparable -> List comparable但我需要一张带有地图字段的记录!
这是我修改过的行,我想用它对列表进行排序.
Submit ->
{ model | teams = List.sort.map (\p -> {p | activated = True}) model.teams, activatedOutput = True}
Run Code Online (Sandbox Code Playgroud) 当我编译我的 ionic 4 应用程序时,我收到此错误:ERROR in Could not resolve module ./services/services.module relative to app/app-routing.module.ts并且模拟未启动。但是,如果我更改代码中的某些内容并再次编译,代码将成功编译。我查了一下,它可能与路径(绝对/相对)有关。但在这些问题中,解决方案是使用相对路径https://github.com/angular/angular-cli/issues/8641或在这个问题Angular 4 - 无法解析子模块进行路由。由于我已经在使用相对路径,我不知道该怎么做。我在这个应用程序中的文件夹结构是 => src/app/pages 或 services。编辑:当我删除带有所有连接的整个服务文件夹时,问题仍然存在。
路由器模块.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { TabsPage } from './tabs.page';
const routes: Routes = [
{
path: 'tabs',
component: TabsPage,
children: [
{
path: 'one',
children: [
{
path: '',
loadChildren: '../one/one.module#OnePageModule'
}
]
},
{
path: 'two',
children: [
{
path: '',
loadChildren: …Run Code Online (Sandbox Code Playgroud) elm ×3
typescript ×2
angular ×1
glowscript ×1
html ×1
ionic4 ×1
javascript ×1
list ×1
python ×1
sorting ×1
syntax ×1
vpython ×1