我试图在两个时间戳之间获得分钟差异
我有一个看起来像这样的时间戳
'15:44:06'
Run Code Online (Sandbox Code Playgroud)
当我想找到时间流逝时,我会创建一个新的时刻时间戳
var currentTimestamp = Moment(new Date()).format('HH:mm:ss');
Run Code Online (Sandbox Code Playgroud)
哪个回来了
'15:42:09'
Run Code Online (Sandbox Code Playgroud)
然后,我试图得到这样的差异
var duration = Moment.duration(Moment(currentTimestamp,'HH:mm:ss').diff(Moment(userTimestamp,'HH:mm:ss')));
Run Code Online (Sandbox Code Playgroud)
然后尝试在几分钟内完成它
var elapsedTime = duration().asMinutes();
console.log(elapsedTime);
Run Code Online (Sandbox Code Playgroud)
但是在我登录时在控制台中我得到了这个错误
var elapsedTime = duration().asMinutes();
^
TypeError: object is not a function
Run Code Online (Sandbox Code Playgroud)
我从这个stackoverflow获得了大部分代码
我正在尝试使用无服务器创建一个 S3 存储桶,它可以工作,但是为了操作其中的文件,我需要一个存储桶策略。我很难理解在何处以及如何添加使用在第一次无服务器部署时创建的生成的 S3bucket 名称的策略
## serverless.yml##
service: vcc-nametags-api
# Use the serverless-webpack plugin to transpile ES6
plugins:
- serverless-webpack
- serverless-offline
- serverless-ding
# serverless-webpack configuration
# Enable auto-packing of external modules
custom:
# Our stage is based on what is passed in when running serverless
# commands. Or fallsback to what we have set in the provider section.
stage: ${opt:stage, self:provider.stage}
# Set our DynamoDB throughput for prod and all other non-prod stages.
# Load our webpack …Run Code Online (Sandbox Code Playgroud) 我在节点/快速服务器上使用svg.js以及svgdom尝试设法操作svg然后将其转换为PNG来构建PDF.
目前,我已经做到了这一点
const window = require('svgdom');
const SVG = require('svg.js')(window);
const document = window.document;
const draw = SVG(document.documentElement);
const fs = require('fs');
const tag = fs.readFileSync(`images/name-tag-1-with-name.svg`,'utf8');
const svg = draw.svg(tag);
Run Code Online (Sandbox Code Playgroud)
这是SVG的布局
<svg id="name-tag" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 216 288">
<defs>
<style>
.cls-1,
.cls-2 {
fill: #414042;
}
.cls-2 {
opacity: 0.95;
}
.cls-3,
.first-name,
.last-name {
fill: #fff;
}
.cls-4 {
fill: none;
stroke: #fff;
stroke-miterlimit: 10;
}
.first-name,
.last-name {
font-size: 30.87px;
font-family: Gibson-SemiBold, Gibson;
font-weight: …Run Code Online (Sandbox Code Playgroud) 我有一段时间试图了解最好的方法来做到这一点,甚至在哪里处理这个重定向.
我找到了一个创建ProtectedRoute像这样设置的组件的例子
const ProtectedRoute = ({ component: Component, ...rest }) => {
return (
<Route {...rest} render={props => (rest.authenticatedUser ? (<Component {...props}/>) : (
<Redirect to={{
pathname: '/login',
state: { from: props.location }
}}/>
)
)}/>
);
};
Run Code Online (Sandbox Code Playgroud)
像这样使用
<ProtectedRoute path="/" component={HomePage} exact />
Run Code Online (Sandbox Code Playgroud)
我redux-thunk用来确保我可以fetch在我的操作中使用异步请求,这些设置是这样的
export const loginSuccess = (user = {}) => ({
type: 'LOGIN_SUCCESS',
user
});
...
export const login = ({ userPhone = '', userPass = '' } = {}) …Run Code Online (Sandbox Code Playgroud) 设置主题时是否有使用主题间距的首选方法createMuiTheme?我一直在对这些值进行硬编码,并且在大多数情况下都没有出现问题,因为我的大多数项目都不会覆盖默认主题间距,但如果能够在我的覆盖中使用主题间距那就太好了?
我不能为我的生活弄清楚为什么我不能循环这个http调用的响应.无论出于何种原因,它抱怨的data是一个对象的类型,但是当我控制台登录时,我可以像我期望的那样使用一个数组.
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { URLSearchParams } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/forkJoin';
promises.push(Observable.create(observer => {
this.http.post(`items/event/${this.event.auction_code}`, body.toString(), {
headers: new HttpHeaders().set('Content-Type', 'application/X-www-form-urlencoded' ),
}).subscribe(data => {
var classifiedData;
data.forEach((item)=>{
classifiedData.push(new Item(item));
});
observer.next(data);
observer.complete();
},error => {
observer.throw(error);
});
}));
...
Observable.forkJoin(promises).subscribe(results => {
results.forEach((result,i)=>{
data.content.template[i].data = result;
});
});
Run Code Online (Sandbox Code Playgroud)
编辑:
Console.log告诉我这个
编辑:2
我也有一个拦截器设置,这可能导致它吗?
@Injectable()
export class NoopInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const …Run Code Online (Sandbox Code Playgroud) 我对如何向使用生成配置文件/证书的应用程序添加推送通知功能有点困惑fastlane match
match我尝试在启用和设置推送通知后在开发中运行我的设备,但不断看到为我生成的开发配置文件不支持这些功能的错误
我已多次尝试破坏开发证书并生成新证书,但它继续创建证书而未启用推送通知功能
我应该经历什么过程来添加推送通知并生成具有推送通知功能的新配置文件/证书?
由于某种原因,我的函数被调用两次,但我似乎不明白为什么。
我在这里看到这个问题
哪个引用了这个github问题
https://github.com/angular/angular/issues/6782
但这似乎表明我正在多个地方导入该文件,但我认为情况并非如此。
据我所知,我正在利用 Ionic 3 的延迟加载功能。
这是一个精简的 github 存储库的链接,您可以在本地运行来查看问题(很抱歉,我无法找出在 plunker 或 codepen 中运行它的最佳方法)
https://github.com/Jordan4jc/ionic-init-example
这个概念是主应用程序首先从商店加载一个令牌,然后验证它,如果它仍然是有效的路由,EventsPage但如果不是,它将路由到LoginPage
在此示例中,我伪造它并假装令牌有效并路由到EventsPage,正如您将在ngOnInit函数中看到的那样(如果我将其移动到构造函数theconsole.log 中,则事件会被调用两次。这将击中我的服务器获取最新数据,所以我真的不想两次调用我的 API。
编辑:这是内容app.component.ts
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import {Storage} from '@ionic/storage';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, storage: Storage) …Run Code Online (Sandbox Code Playgroud) 我似乎无法弄清楚这一点。有人可以帮我解决这个问题吗?我正在使用 CodePush 上传我的应用程序,并且我希望 Sentry 处理我的错误,因为应用程序中心诊断不是很好。
我的应用程序的根组件中有这个......
if (process.env.NODE_ENV === 'production') {
Sentry.config('****',{
deactivateStacktraceMerging: false
}).install();
codePush.getUpdateMetadata().then((update) => {
if (update) {
Sentry.setVersion(update.appVersion + '-codepush:' + update.label);
}
});
}
Run Code Online (Sandbox Code Playgroud)
我有一个部署包脚本,它将部署到 codepush 并运行在其文档中找到的哨兵命令
appcenter codepush release-react -a account/project --output-dir ./build && export SENTRY_PROPERTIES=./ios/sentry.properties && sentry-cli react-native appcenter account/project ios ./build/codePush
每当我捕获到一个错误或捕获到一个错误时,我都缺乏有关哪个文件引发错误的实际信息,并且我会There was 1 error encountered while processing this event在顶部看到Source code was not found for app:///main.jsbundle当我展开它时的信息。
我觉得这一定是因为哨兵没有正确连接到 codepush 来获取我的源映射?
我正在尝试制作一个小应用程序来快速教自己一些我在解决如何使我的应用程序以某种方式运行时遇到一些问题.
我的应用程序应该能够播放一个无声的声音,就像它在这个视频中的声音一样......
https://www.youtube.com/watch?v=Ks5bzvT-D6I
但每次我重复点击屏幕时,声音播放前会有一点延迟,所以听起来根本就不是这样.
import UIKit
import AVFoundation
class ViewController: UIViewController {
var audioPlayer = AVAudioPlayer()
override func viewDidLoad() {
super.viewDidLoad()
var hornSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("horn", ofType: "mp3")!)
AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, error: nil)
AVAudioSession.sharedInstance().setActive(true, error: nil)
var error:NSError?
audioPlayer = AVAudioPlayer(contentsOfURL: hornSound, error: &error)
audioPlayer.prepareToPlay()
}
@IBAction func playSound(sender: UIButton) {
audioPlayer.pause()
audioPlayer.currentTime = 0
audioPlayer.play()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Run Code Online (Sandbox Code Playgroud)
我也遇到过关于使用spritekit的这个帖子
并且试着让它在没有延迟的情况下播放声音,但是使用精灵套件我无法阻止现有声音,所以它们只是重叠而不是我想要的效果.
是否有解决方案让它按照视频中的声音工作.
ios ×2
react-native ×2
reactjs ×2
amazon-s3 ×1
angular ×1
angularjs ×1
audio ×1
avfoundation ×1
code-push ×1
difference ×1
duration ×1
fastlane ×1
ionic3 ×1
javascript ×1
material-ui ×1
momentjs ×1
node.js ×1
react-redux ×1
redirect ×1
rxjs ×1
sentry ×1
svg ×1
svg.js ×1
swift ×1
themes ×1
typescript ×1
xcode ×1