到目前为止,我已成功完成以下工作:
✓HMR(热模块重新加载)设置
✓角度(5)和材料运行良好
✓打开一个对话框(下面的代码片段)
// ...
constructor(private dialog: MatDialog){}
//...
public openDialog(){
this.dialogRef = this.dialog.open(someDialogComponent, {
width: '300px'
});
}
Run Code Online (Sandbox Code Playgroud)
✓在对话框或对话框的父控制器上进行更改
✓MMR被触发(yay)
✖对话框挂起死机状态,由于对话框和背景被"卡住"而无法点击,页面基本上被冻结
我试图挂钩ngOnInit和ngOnDestroy在父或对话框控制器中关闭对话框引用,如果存在,我也尝试过dialog.closeAll(),但这没有用.此外,理想情况下,对话框不必关闭,但我似乎无法修复此僵尸对话框问题.
有没有遇到过这个?
在室内,@Delete注释不会发出任何东西.这就是它的dao样子
@Dao
public interface UserDao {
@Delete
void deleteUser(User user);
//We can't use Maybe or Single or anything here
}
Run Code Online (Sandbox Code Playgroud)
这使得在做类似事情时出现问题
userRepository.deleteUser().subscribeOn因为我们没有排放dao.我使用以下代码在后台线程上调用deleteUser.
Observable.just(appDatabase).
subscribeOn(SchedulerProvider.getInstance().computation()).
subscribe(db -> {
userRepository.logoutUser(loggedUser.getLoggedInUser());
loggedUser.setLoggedInUser(null);
}, this::handleError);
Run Code Online (Sandbox Code Playgroud)
这很好用.但是,在订阅方法中,我现在需要访问Android UI以显示宣布成功删除的Toast.当然,我得到这个例外(因为链中缺少observeOn)
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
Run Code Online (Sandbox Code Playgroud)
但是,当我把observeOn这样的
Observable.just(appDatabase).
subscribeOn(SchedulerProvider.getInstance().computation()).
observeOn(SchedulerProvider.getInstance().ui()).
subscribe(db -> {
userRepository.logoutUser(loggedUser.getLoggedInUser());
loggedUser.setLoggedInUser(null);
Message message = new Message(R.string.user_logged_out_msg);
message.setMessageType(Message.MessageType.SUCCESS_MESSAGE);
view.showMessages(Arrays.asList(message)); //this leads to a taost
}, this::handleError);
Run Code Online (Sandbox Code Playgroud)
我奇怪地得到这个例外:
cannot access database …Run Code Online (Sandbox Code Playgroud) 我正在将Material-UI用于React项目。但是,我不确定如何全局应用主题。
在这里,我尝试了单个组件
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
import CardCommon from '../../common/card/CardCommon';
import purple from '@material-ui/core/colors/purple';
import Button from '@material-ui/core/Button';
import { Link } from 'react-router-dom';
//const primary = red[500]; // #F44336
import { Paths } from '../../../Routes';
const theme = createMuiTheme({
palette: {
primary: { main: purple[500] }, // Purple and green play nicely together.
secondary: { main: '#11cb5f' }, // This is just green.A700 as hex.
},
});
Run Code Online (Sandbox Code Playgroud)
那么如何在全局范围内更改原色和副色?
我无法强迫mat-card-title保持在一行并切断多余的文本。
我已经尝试过下面的 css 类(text-oneline)。
<mat-card>
<mat-card-header>
<mat-card-title class="text-oneline">Heeeeeellllllloooo</mat-card-title>
<mat-card-subtitle>World!</mat-card-subtitle>
</mat-card-header>
<img mat-card-image [src]="icon_url" alt="App Icon">
<mat-card-content>
<p>Some Text</p>
</mat-card-content>
<mat-card-actions>
<button mat-button>Hello</button>
</mat-card-actions>
</mat-card>
Run Code Online (Sandbox Code Playgroud)
<mat-card>
<mat-card-header>
<mat-card-title class="text-oneline">Heeeeeellllllloooo</mat-card-title>
<mat-card-subtitle>World!</mat-card-subtitle>
</mat-card-header>
<img mat-card-image [src]="icon_url" alt="App Icon">
<mat-card-content>
<p>Some Text</p>
</mat-card-content>
<mat-card-actions>
<button mat-button>Hello</button>
</mat-card-actions>
</mat-card>
Run Code Online (Sandbox Code Playgroud)
现在,文本比卡片长。我希望文字停止而不是溢出卡片。我希望文本填满所有可用空间,但不要超过垫卡的宽度。
示例:https : //angular-mat-card-example-4cb2wk.stackblitz.io
解决方案:
代码由 ???? ???效果很好,但只有在 window.resize 被触发之后。我发现的简单解决方案是编辑mat-card-header.
.text-oneline {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
Run Code Online (Sandbox Code Playgroud) 我尝试从 api 使用自动完成,但它不起作用。它只有在没有 api 的情况下才能工作。
这是我的组件 TS:在那里,有一个带有来自 api (onGetTaxList) 的数据的回调方法
import { Component, OnInit } from '@angular/core';
import { UsersService } from '../../../../core/services/users.service';
import { FormControl } from '@angular/forms';
import { Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
@Component({
selector: 'app-create-process-modal',
templateUrl: './create-process-modal.component.html',
styleUrls: ['./create-process-modal.component.sass']
})
export class CreateProcessComponent implements OnInit {
myControl = new FormControl();
options = [
{ name: 'One' },
{ name: 'Two' },
{ name: 'Tree' },
];
filteredOptions: Observable<any>;
constructor(private service: …Run Code Online (Sandbox Code Playgroud)一直尝试在模板字符串中添加条件。我做不到。我有两个字符串,即 t1 和 t2,当 t2 未定义或为空时,仅显示 t1,当 t2 存在时,将 t2 与 t1 一起附加在括号内
let t1= "hey";
let t2 = "there";
//need the output something like hey(there) when there t2 is present. when it is null or undefined or empty just show hey
//Have tried the below but it is not working
console.log(`${t2} ${t1} ? ${t1}(${t2}): ${t1}`)
Run Code Online (Sandbox Code Playgroud) 我正在关注这篇文档文章,目前我有以下代码:
echo '::add-path::$HOME/.local/bin'
Run Code Online (Sandbox Code Playgroud)
然而,这不起作用。我尝试了单引号和双引号。我唯一的猜测是它不喜欢$HOME,但我真的很想避免硬编码/home/runner与主目录无关。
有没有办法在 GitHub Actions 中添加本地路径?
当我在我的应用程序上做自定义 Toast 时,我注意到 setView 已被弃用。
有没有人对此有解决方案?
toast.setView(customView);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 .angular4 项目创建mdc-componentsangular-cli。所以我使用 npm 命令安装了 moduled
npm install material-components-web
Run Code Online (Sandbox Code Playgroud)
这个安装了
"material-components-web": "^0.22.0"
Run Code Online (Sandbox Code Playgroud)
然后创建了一个包含滑块的 HTML 标记的组件
<div #slider class="mdc-slider" tabindex="0" role="slider" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" aria-label="Select Value">
<div class="mdc-slider__track-container">
<div class="mdc-slider__track"></div>
</div>
<div class="mdc-slider__thumb-container">
<svg class="mdc-slider__thumb" width="21" height="21">
<circle cx="10.5" cy="10.5" r="7.875"></circle>
</svg>
<div class="mdc-slider__focus-ring"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在 ts 端使用 ViewChild
@ViewChild('slider') elSlider: ElementRef;
Run Code Online (Sandbox Code Playgroud)
并使用MDCSlider类包装此元素
let mdcSlider = new MDCSlider(this.elSlider.nativeElement);
Run Code Online (Sandbox Code Playgroud)
然后为文件中的同一个 mdc 组件导入 sassstyles.scss文件
@import '~@material/slider/mdc-slider';
Run Code Online (Sandbox Code Playgroud)
这在 UI 上呈现了一个漂亮的材质滑块组件,并且工作正常。
监听更改事件
mdcSlider.listen('MDCSlider:change', () => console.log("Value changed …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Material 提供的 CircularProgress。
我创建了这个组件来改变它的颜色:
import React, { Component } from 'react';
import { withStyles } from '@material-ui/core/styles';
import { CircularProgress } from '@material-ui/core';
class ColoredCircularProgress extends Component {
render() {
const { classes } = this.props;
return <CircularProgress {...this.props} classes={{colorPrimary: classes.colorPrimary}}/>;
}
}
const styles = props => ({
colorPrimary: {
backgroundColor: '#FD8907',
}
});
export default withStyles(styles)(ColoredCircularProgress);
Run Code Online (Sandbox Code Playgroud)
但是在我的网站上它看起来像这样:
我的问题是:
我希望圆圈看起来是橙色的,而圆圈看起来仍然是蓝色的,它在后面添加了一个橙色的方形框。
它也显示在我网站的左上角。我怎样才能把它放在中间?
angular ×4
javascript ×3
android ×2
material-ui ×2
reactjs ×2
android-room ×1
autocomplete ×1
css ×1
ecmascript-6 ×1
java ×1
react-redux ×1
rx-android ×1
rx-java2 ×1
webpack-hmr ×1