我使用的语言和库是JS和AngularJS。我以为“插值”和“串联”都意味着“字符串和变量的组合”,对吗?
但是,当您在AngularJS中使用双花括号时,将使用“插值”。当您使用纯JS时会使用“连接”吗?
还是我错过了另一个区别?
编辑:这是插值或串联(我不只是把字符串放在一起,而是在这里解析了一个变量)?
var test1 = "Hello";
var number = 2 + 3;
console.log(test1 + " " + number);
Run Code Online (Sandbox Code Playgroud)
嗯....我想每当我使用AngularJS库组合一些表达式时,就进行插值,对吗?
我收到此错误:"TypeError:d.$$ minErr不是函数".这似乎是角度路线的问题.
我的代码:index.htm:
<!DOCTYPE html>
<html ng-app="myApp" lang="en">
<head>
<script src="js/angular.min.js"></script>
<script src="js/angular-route.min.js"></script>
<script src="app.js"></script>
<meta charset="utf-8"/>
</head>
<body>
<search-result></search-result>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
app.js
var myApp = angular.module('myApp', ['ngRoute']);
myApp.config(function($routeProvider){
$routeProvider
.when('/', {
templateUrl: 'pages/main.html',
controller: 'mainController'
})
});
// controllers
myApp.directive('searchResult', function() {
return {
restrict: 'AECM',
templateUrl: 'customDirectivePage.html',
replace: true
}
});
Run Code Online (Sandbox Code Playgroud) 我有这个HTML结构:
<body cz-shortcut-listen="true">
<div id="panels">
<section id="sect0" name="lvl0">
<div id="divLvel0" class="level zero">
<h2>top<nav><ul><li><a href="#sect1">Languages</a></li><li><a href="#sect2">Proficiency</a></li><li><a href="#sect3">Milestones</a></li><li><a href="#sect4">Details</a></li></ul></nav></h2>
</div>
</section>
<section id="sect1" name="lvl1">
<div id="divLvel1" class="level one">
<div id="panel_lvl1">
<h2>Languages</h2>
</div>
</div>
</section>
<section id="sect2" name="lvl2">
</section>
<section id="sect3" name="lvl3">
<div id="divLvel3" class="level three">
<div id="panel_lvl3">
<h2>Milestones</h2>
<div id="chart3">
</div>
</div>
</div>
</section>
<section id="sect4" name="lvl4">
<div id="divLvel4" class="level four">
<div id="panel_lvl4">
<h2>Details</h2>
<div id="chart4">
</div>
</div>
</div>
</section>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
https://jsfiddle.net/thadeuszlay/Lkdo5xv3/2/
每个部分直接相互接触,即部分之间没有其他元素.但不知何故,你可以看到每个部分之间的间隙(绿色背景颜色).
我已经将填充和身体边缘设置为零.我也用DIV替换了这些部分.但差距仍然存在.
如何摆脱差距,使每个部分接触到其他部分而没有间隙?
我想设置警报,以防CloudWatch上的CloudFront发生错误。
在控制台中,我将直接创建一个警报,如果TotalErrorRate大于0 ,它将向我发送电子邮件。
但是现在我想在CloudFormation的yaml模板文件中设置相同的设置。我很难找出相应参数的正确值。我的文件当前如下所示:
# CloudWatch
CloudFrontTotalErrorRateAlarm:
Type: "AWS::CloudWatch::Alarm"
Properties:
ActionsEnabled: Boolean
AlarmActions:
- String
AlarmDescription: "Trigers an alarm if there is any error (e.g. 4xx,5xx)"
AlarmName: "MyApiTotalErrorRate"
ComparisonOperator: GreaterThanThreshold
Dimensions:
- Dimension
EvaluationPeriods: "1"
ExtendedStatistic: String
InsufficientDataActions:
- String
MetricName: TotalErrorRate
Namespace: AWS/CloudFront
OKActions:
- String
Period: 60
Statistic: String
Threshold: 0
TreatMissingData: String
Unit: String
Run Code Online (Sandbox Code Playgroud)
对于某些参数,我可以算出实际值是多少。但是对于其他人,我基本上不知道应该输入什么内容,以便AWS可以在发生错误的情况下向我发送电子邮件。以下参数是缺少的值:
ActionsEnabledAlarmActionsDimensionsExtendedStatisticInsufficientDataActionsOKActionsStatisticTreatMissingDataUnitamazon-web-services aws-cloudformation amazon-cloudwatch amazon-cloudwatch-metrics
如何将参数传递给样式化组件?
我试图创建一个接口和一个样式化的组件:
export interface StyledContainerProps {
topValue?: number;
}
export const StyledContainer: StyledComponentClass<StyledContainerProps> = styled.div`
position: absolute;
top: `${props.topValue || 0}px`;
`;
Run Code Online (Sandbox Code Playgroud)
然后我要像这样使用它:
<StyledContainer
topValue={123}
>
This has a distance of 123px to the top
</StyledContainer>
Run Code Online (Sandbox Code Playgroud)
但这是说props没有属性topValue。
我想插入一个操作符,例如i手动插入我的宏寄存器.所以,如果我想插入i运算符(在光标后插入),我这样做:
:let @x="\ihello\n"
x多次执行宏时,例如3@x我得到这个结果:
hello
ihello
ihello
Run Code Online (Sandbox Code Playgroud)
Vim认可了这条新线\n.但只承认\i一次.对于剩余的行,vim将命令打印\i为字符串'i'.
如何插入vim命令(i用于插入,<esc>转义,删除等)?