我正在使用Angular2 + WebPack + Typescript 1.7 stack + SASS + CommonJs.
我有webpack SASS加载器配置为使用"style!css!sass"加载器来监视scss文件.
在我的组件中,我有@View装饰器,它包含样式或styleUrls参数,可用于传递此组件的内联样式或样式URL.
如果我将指定其中一个@View参数,Angular2会自动加载指定的css文件或(或将内联css),这对我有用.
但是如果我将使用sass-loader + require(),这将使我能够将scss编译为css并将其内置到我的js文件中(我使用ts-loader并将所有脚本合并到app.js中) .
所以我可以使用stylesUrl通过Angular2自动预加载css文件.
@View({ stylesUrl: 'my.css'}) export class Component{}
Run Code Online (Sandbox Code Playgroud)
或者我可以使用require('*.scss')将css合并到我的app.js中
require('styles/my.scss');
@View({}) export class Component{}
Run Code Online (Sandbox Code Playgroud)
对此更好的方法是什么,我的意思是Angular2方式?
此外,我可以从所有scss文件预构建一些common.css,并且只是避免为组件指定任何样式.而且index.html中只包含1个common.css + common.css.map文件(用于调试)
PS关于最后一种方法(合并所有css文件)
//webpack.config.js
loaders: [
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', ['css?sourceMap', 'sass?sourceMap']),
include: path.join(__dirname, 'src', 'styles'),
}
...
plugins: [
new ExtractTextPlugin("assets/path/styles.css?[hash]-[chunkhash]-[contenthash]-[name]", {
disable: false,
allChunks: true
})
//index.html
<link rel="stylesheet" href="assets/path/styles.css" />
Run Code Online (Sandbox Code Playgroud)
所以现在我有CDN供应商链接到css.所有我的自定义css(用scss编写)都合并到1个文件styles.css中,它们为所有组件加载一次.
此方法启用了sourceMap.但澄清在调试中修改哪个scss文件有点棘手..而且Angular @View声明中也没有任何信息
我需要向 JSON 架构添加一个可选属性。该属性是Enum类型。如果用户未指定此字段,我需要设置默认值。
// schema
"properties" : {
"Param" : {
"type" : "string",
"enum" : [ " p1", "p2" ],
"optional" : true,
"default" : "p2",
"required" : true
}
}
Run Code Online (Sandbox Code Playgroud)
如果用户不指定“Param”字段,则应将字段识别为“p2”
我正在使用 .NET 4.5 和 EF 6.0(也尝试过 6.1.3)。我在实体表(System.Data.Entity.Spatial.DbGeography )中有位置地理列。
using System.Data.Spatial; //also tried Entity one
public class Entity
{
public DbGeography Location {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
在 LINQ 中,我尝试选择指定区域内的所有实体。
var center = DbGeography.FromText(string.Format("POINT({0} {1})", latitude, longitude), 4326);
var region = center.Buffer(radius);
var result = db.Entities.Where(x => SqlSpatialFunctions.Filter(x.Location, region) == true).ToArray();
Run Code Online (Sandbox Code Playgroud)
这个查询返回一个错误:
An unhandled exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll
Additional information: The specified type member 'Location' is not supported in LINQ to Entities. Only initializers, entity members, and entity …Run Code Online (Sandbox Code Playgroud) 在官方文档中指出,::它比@。
一旦所有列表在F#中都是不变的,为什么会有区别?无论如何,都应复制原始列表。但是如果::有的话我们会在前面加上,如果有的话我们会在后面加上@。它应该是相同的复杂性。
有什么不同?
我在单一回购中有 2 个 CRA 项目 - P1 和 P2。
root/
projects/
p1/
package.json
tsconfig.json
src/
shared/
**/*.ts
p2/
package.json
tsconfig.json
src/
**/*.ts
Run Code Online (Sandbox Code Playgroud)
P1包含一些共享基础设施源文件,我想在P2.
注意:我知道这种方法的缺点和负面影响,但是......
我试过的:
包括P1从P2和导入:
P1 tsconfig.json 修改为
"include": [..., "root/projects/p1/src/shared/**/*.ts]
P2 源文件通过相对路径导入 .ts 文件结果:
You attempted to import <path> which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from …Run Code Online (Sandbox Code Playgroud)我有TextBlock
<TextBlock>
<Run Text="{Binding Path=Value1}" />
<Run Text="-" />
<Run Text="{Binding Path=Value2}" />
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
我需要添加这样的触发器:如果Value2 = XXX,TextBlock应该只显示Value1.没有转换器和ViewModel修改可以做到吗?
有必要定义
<add key="AWSRegion" value="us-east-1"/>
Run Code Online (Sandbox Code Playgroud)
App.config 中的应用程序设置以指定要使用的区域。
我需要以编程方式改变它
var creds = new BasicAWSCredentials(key, token);
using (var routes = AWSClientFactory.CreateAmazonRoute53Client(creds)){}
Run Code Online (Sandbox Code Playgroud)
如何在代码中指定区域?
我有一个记录类型
record Test(int Magic);
Run Code Online (Sandbox Code Playgroud)
我想定义一些不需要可配置的常量值,例如这样我就可以像这样访问它
Test.MyMagicConst
Run Code Online (Sandbox Code Playgroud)
在 F# 中,我可以使用模块来定义与记录类型同名的常量。
在 C# 和记录中是否可以实现类似的功能?
c# ×4
.net ×1
angular ×1
asp.net-core ×1
aws-sdk ×1
cons ×1
f# ×1
geospatial ×1
json ×1
json.net ×1
jsonschema ×1
list ×1
performance ×1
sass ×1
typescript ×1
webpack ×1
wpf ×1
xaml ×1
yarnpkg ×1