我想在img标签中显示一个图像:我这样做
零件
this.file.url=this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(this.file.url));
Run Code Online (Sandbox Code Playgroud)
模板
<img [src]="file.url">
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误
ERROR TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided.
Run Code Online (Sandbox Code Playgroud) 尝试按照Angular Material的示例创建一个带有清除按钮的输入,链接到该示例,我想要的是在按键输入事件上获取输入值。
HTML:
<mat-form-field>
<input matInput (keydown.enter)="applyFilter($event)" placeholder="Search"
name="search" [(ngModel)]="searchValue">
<button mat-icon-button matSuffix aria-label="Clear" (click)="clearSearch()">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
TS:
applyFilter(event: any) {
console.log(JSON.stringify(event));
}
Run Code Online (Sandbox Code Playgroud)
打印事件内容时控制台的结果:
{"isTrusted":true}
Run Code Online (Sandbox Code Playgroud) 我正在制作这种风格,使用阴影和海拔为android:
shadowColor: colors.shadowColor,
shadowOpacity: 0.5,
shadowRadius: 3,
shadowOffset: {
height: 0,
width: 0,
},
elevation: 2,
Run Code Online (Sandbox Code Playgroud)
我正在安装现有项目的一些 python 包,但出现此错误:
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft
Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
Run Code Online (Sandbox Code Playgroud)
我找到了一个解决方案,通过使用这里StackOverflow answer的 Visual Studio 产品之一安装它,但是,想知道是否有另一种方法而无需安装超过 1.7 gb。PS:我安装了独立的 MSbuild 工具,但对我不起作用。
我想从 illustrator 生成的 SVG 文件中渲染图像,我使用的是react-native 0.59、react-native-svg和react-native-svg-uri,这是我的jsx:
<View style={styles.aboutSection}>
<SvgUri
width="150"
height="150"
source={require('../../assets/images/logo_blue.svg')}
/>
</View>
Run Code Online (Sandbox Code Playgroud)
和我的 SVG 文件:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-574 823.3 20 14" style="enable-background:new -574 823.3 20 14;" xml:space="preserve">
<style type="text/css">
.st0{fill:#2A327B;}
</style>
<g>
<g transform="translate(-320.000000, -1983.000000)">
<g transform="translate(40.000000, 1680.000000)">
<path class="st0" d="M-284,1140.3c-7.4,0-10-7-10-7s3.4-7,10-7c6.7,0,10,7,10,7S-277.3,1140.3-284,1140.3L-284,1140.3z
M-284,1129.3c-2.2,0-4,1.8-4,4s1.8,4,4,4s4-1.8,4-4S-281.8,1129.3-284,1129.3L-284,1129.3z M-284,1135.3c-1.1,0-2-0.9-2-2
s0.9-2,2-2s2,0.9,2,2S-282.9,1135.3-284,1135.3L-284,1135.3z"/>
</g>
</g>
</g>
</svg>
Run Code Online (Sandbox Code Playgroud)
并且在调试时没有显示我缺少的内容以及是否有更好的方法来显示 SVG …