离子的背景地理定位插件未更新.我想要的功能是每30秒向插件询问一个lat lng值(如果可用).问题是,它只是给我最初的值,然后背景停止.前景很好,它确实是背景.基本上我无法在后台第一次初始发送后发送请求.
gps.ts
startTracking() {
console.log('started tracking')
const config: BackgroundGeolocationConfig = {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
debug: false, // enable this hear sounds for background-geolocation life-cycle.
stopOnTerminate: false
};
this.backgroundGeolocation.configure(config)
.subscribe((location: BackgroundGeolocationResponse) => {
this.zone.run(() => {
this.lat = location.latitude
this.lng = location.longitude
this.bearing = location.bearing
this.speed = location.speed
this.accuracy = location.accuracy
this.timestamp = location.time
})
this.backgroundGeolocation.finish(); // FOR IOS ONLY
this.backgroundGeolocation.stop()
});
this.backgroundGeolocation.start();
}
sendGPS(){
this.optionsService.sendGPS(gpsData).subscribe(result => {
}
})
}
stopTracking() {
this.sendGPS()
}
Run Code Online (Sandbox Code Playgroud)
app.component.ts
constructor(){ …Run Code Online (Sandbox Code Playgroud) 我正在配置一个vue项目.我使用了webpack模板.(npm install init webpack).我在终端收到错误 -
ERROR in ./src/main.js
? http://eslint.org/docs/rules/no-new Do not use 'new' for side effects
/Users/uz067252/Documents/Development/Vue/workex/vue-project/src/main.js:21:1
new Vue({
^
? 1 problem (1 error, 0 warnings)
Errors:
1 http://eslint.org/docs/rules/no-new
Run Code Online (Sandbox Code Playgroud)
这是main.js
import Vue from 'vue'
import App from './App.vue'
import Hello from './components/Hello.vue'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource'
// We want to apply VueResource and VueRouter
// to our Vue instance
Vue.use(VueResource)
Vue.use(VueRouter)
// Pointing routes to the components they should use
var router = new …Run Code Online (Sandbox Code Playgroud) 我有充满活力array的物品和价值观.当用户单击项目上的按钮时,它应该从视图列表中删除该项目.我完全没猜到为什么会这样.它是如何构建数据的?我不这么认为,因为它表明它正在控制台中删除.无论如何谢谢!
TS:
export class Page{
items: Item[];
constructor(public alertCtrl: AlertController){}
removeitem(i) {
let confirm = this.alertCtrl.create({
title: 'Confirm',
message: "text.",
buttons: [
{
text: 'Cancel',
handler: () => {
console.log('Disagree clicked');
}
},
{
text: 'Save',
handler: () => {
this.presentToast()
this.items.splice(i, 1);
}
}
]
});
confirm.present();
}
getItems(){
this.stopService.getItems().subscribe(item => {
this.items = item
})
}
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div *ngFor="let item of items; index as i ">
<h3>{{item.description}}</h3>
<button item-end ion-button full (click)="removeitem(i)">remove item</button>
</div>
Run Code Online (Sandbox Code Playgroud)
编辑 …
页面上显示一个按钮.当用户选择子组件将出现的按钮时,会出现以下错误 - 错误:未捕获(在承诺中):错误:找不到ModalComponent的组件工厂.你有没有把它添加到@ NgModule.entryComponents?
我设置的结构如下,这与Ionic 3一起 -
app (folder)
- app.module
- app.component
components (folder)
- modal-component.ts
pages (folder)
- pageOne (folder)
- pageOne.module
- pageOne.ts
Run Code Online (Sandbox Code Playgroud)
我把模态组件放在pageOne.module中
pageOne.module
@NgModule({
declarations: [
pageOne,
modalComponent
],
entryComponents: [
modalComponent
],
imports: [
IonicPageModule.forChild(pageOne),
],
exports: [
pageOne,
]
})
export class pageOneModule {}
Run Code Online (Sandbox Code Playgroud)
pageOne.ts
@IonicPage()
@Component({
selector: 'pageOne',
templateUrl: 'pageOne.html',
})
export class pageOne {}
Run Code Online (Sandbox Code Playgroud) 在下面的代码中,我发布了两个代码在控制台中返回的示例.对于拦截器,我应该返回一个可观察的.我已将本地存储承诺转换为使用switchmap的可观察对象.我仍然使用这种方法返回null.我的observable包含在函数中,所以我应该得到一个null以外的值.谢谢!
Interceptor.js
import { fromPromise } from 'rxjs/observable/fromPromise';
accessToken: string;
emptyToken: any;
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
//example
this.storage.get('token').then((val) => {
this.accessToken = val
return console.log(this.accessToken, ' this is returning null value for token')
})
//trying to return actual header
return fromPromise(this.storage.get('token')).switchMap(access => {
this.accessToken = access
console.log(this.accessToken, ' this is returning null value for token')
const authReq = req.clone({
setHeaders: {
Authorization: this.accessToken
}
});
return next.handle(authReq)
})
}
}
Run Code Online (Sandbox Code Playgroud)
我已经添加了下面更新的代码,请忽略上面的代码并仍然得到相同的结果.作为下面所述的答案之一,它们在所有假设中都是正确的.归结为将令牌置于登录observable内部.问题不在于拦截器,代码工作正常.我需要以某种方式获取我的异步值而不返回null.this.storage.ready()方法也给了我相同的结果.我的拦截器后调用了auth服务,因此我还没有生成任何令牌.我将如何首先调用我的身份验证服务?
login(userName: string, password: string, route: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用自定义组件创建样式指南。我需要能够在彼此之间插入组件,并且不确定如何在.md文件内部进行插入。我有一个清单和清单项目。我想在列表中显示列表项。在styleguidist显示中出现此错误。这是一些很好的例子,但没有一个例子说明我要完成的工作-https: //github.com/styleguidist/react-styleguidist/tree/master/examples/basic/src/components
语法错误:意外的令牌(3:0)1:从'./ListItem'中导入ListItem 2:3:
List.tsx
import React, { Component } from 'react'
import './List.css'
export interface IListProps {
/** Type of button to display */
font: string;
disabled: boolean;
mtmClass: string;
link: boolean;
}
class List extends Component<IListProps> {
render() {
const { children } = this.props
return <ul className={'mtm-list'}>{children}</ul>
}
}
export default List
Run Code Online (Sandbox Code Playgroud)
List.md
```js
import ListItem from './ListItem'
<List>
<ListItem>
Content in a List
</ListItem>
</List>
Run Code Online (Sandbox Code Playgroud)
ListItem.tsx
import React, { Component } from 'react'
import './List.css'
export …Run Code Online (Sandbox Code Playgroud) 我在我的node/express应用程序的服务器端验证JWT时遇到问题.该令牌是在asp.net核心应用程序中的Identity Server中生成的.生成的令牌是RS256令牌类型,这意味着需要在Identity Server中创建时生成私钥和公钥.这对我意味着什么 -
在客户端(Angular),我在登录后的所有请求中传递了Bearer令牌.我需要以某种方式验证该令牌.使用RS256令牌类型的方法是确保公钥匹配.我正在使用
const jwt2 = require('jwt-simple');
对于我的JWT验证.
问题是秘密,这里是jwt-simple文档jwt-simple链接.如果我在解码中使第三个值为false,那么它可以工作,因为它忽略了所需的秘密/证书.
我收到这个错误 -
错误:错误:0906D06C:PEM例程:PEM_read_bio:无起始行
我正在中间件中进行此验证,因此所有端点都会触及它.我看到了这个问题 - 类似的问题并运行了相同的命令.我仍然收到错误,因为令牌与证书没有任何关系,因为我从Identity Server项目中获取它.所以我需要从该项目中检索cert公钥.
我怎样才能在令牌中发送该证书或以某种方式检索该有效证书?希望这有一定道理.任何帮助,将不胜感激.
v1 - (使用自签名server.crt作为证书并获取此错误)
错误:签名验证失败
App.js
//This is for a self-signed certificate locally with no correlation to the token itself.
const options = {
key: fs.readFileSync('./key.pem', 'utf8'),
cert: fs.readFileSync('./server.crt', 'utf8')
};
app.use((req, res, next) => {
if(!req.headers.authorization){
return res.status(403).json({ error: 'No credentials sent!'});
} else {
let token = req.headers.authorization.split(' ')[1]
var decoded = jwt.decode(token, options.cert);
if(decoded){
let currentTime …Run Code Online (Sandbox Code Playgroud) 我正在制作一个指导我部分.本指南的部分内容 - 显示一系列流程.每个进程内都有一个步骤数组,每个步骤中都有一个选项数组.用户从其中一个步骤中选择一个选项,将它们带到下一个相关步骤.如果用户在步骤2中选择了该选项,则可以将它们带到步骤3或返回步骤1.这取决于id.
尽管如此,我的过程中有一些问题在改变我.我正在使用React Context作为全局状态.当用户选择一个选项时,我抓住那个id,然后通过该id过滤指定的对象.所以我只能留下具有该特定步骤的流程.发生的事情是我最初的全球状态正以某种方式发生变异.我在这里错过了一些东西,因为我是React的新手.
Ps - 我现在没有使用任何服务,所以我只是将一些JSON复制到context.js中的初始状态
context.js
import React, { Component } from 'react'
// import axios from 'axios'
const Context = React.createContext()
const reducer = (state, action) => {
switch(action.type){
case 'SEARCH_PROCESS':
return {
...state,
guides: action.payload
}
default:
return state
}
}
export class Provider extends Component {
state = {
guides: [
{
"processName": "Support Messaging",
"steps": [{
"id": "15869594739302",
"title": "step one",
"options": [{
"nextStep": "4767fn-47587n-2819am-9585j,04956840987",
"text": "Option 1 text",
"type": "option"
},
{ …Run Code Online (Sandbox Code Playgroud) javascript state-management reactjs react-context react-state-management
当用户选择列表项时,应显示与该列表项关联的表.我有脑筋,我想我已接近解决它或者至少是关于如何解决问题的想法.找到每个的长度,如果长度彼此相等,则创建显示/单击功能.答案应该是可以用于具有不同表的数百个列表项的答案.
HTML
<div>
<ul>
<li id='one'><a href="#">number</a></li>
<li id='two'><a href="#">othernumber</a></li>
</ul>
</div>
<div>
<table>
<thead>
<tr>
<th>title</th><th>title</th><th>title</th><th>title</th>
</tr>
</thead>
<tbody id="table1">
<tr>
<td>blah</td>
<td>blah</td>
<td>blah</td>
<td>blah</td>
</tr>
</tbody>
<tbody id="table2" style="display:none">
<tr>
<td>blahTwo</td>
<td>blahTwo</td>
<td>blahTwo</td>
<td>blahTwo</td>
</tr>
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
JS
function count(){
var list = jQuery('ul li')
var table = jQuery('table tbody')
if(table.length == list.length){
jQuery(list).click(function(){
//show the table length that is equal to the list length
})
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个固定的页脚。我有一个相对的标题。在这些容器之间有设置为overflow-y:auto的内容。这意味着滚动条应该仅在该 div 容器中显示。我在这个内容 div 周围有一个容器。该 div 的高度设置为像素,因为使用百分比时,它会自动变为 100% 并且滚动条不可见。在不改变屏幕高度的情况下,它看起来 100% 完美。但是,如果用户要更改屏幕的高度,则用户将无法看到 div 中的所有内容,因为固定页脚现在覆盖了该内容。当用户缩小时,页脚和 div 之间有一个空白。我希望这样当用户缩小时没有空白区域,并且当用户更改屏幕高度时,用户可以查看所有内容。
超文本标记语言
<div class="top-container">
</div>
<div class="container">
<ul>
<li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li>
</ul>
</div>
<footer>
</footer>
Run Code Online (Sandbox Code Playgroud)
CSS
.top-container {
position: relative;
z-index: 6;
background: #fff;
padding: 40px 40px 0;
bottom: 0;
width: 100%
}
.container {
padding: 10px 0;
margin: 0 .6%;
}
ul {
padding-top: 2px;
height: 437px;
overflow-y: auto;
overflox-x: hidden;
}
footer{
background: #fff;
padding: 20px 50px;
overflow: hidden;
position: fixed;
z-index: 5;
left: 0;
bottom: …Run Code Online (Sandbox Code Playgroud) 抱歉,这是一个菜鸟问题,但问题就在这里:
我希望管理员(登录网站时)查看非管理员登录时无法查看的链接。我什至不知道如何开始。我知道我必须在route.js文件中添加两条单独的路由。但不是很确定如何在用户界面中显示它,或者我什至不正确。
这个仓库似乎与我的问题有关。https://github.com/angular-ui/ui-router#get-started
谢谢
javascript ×6
angular ×4
ionic2 ×4
node.js ×3
html ×2
ionic3 ×2
reactjs ×2
typescript ×2
asp.net-core ×1
css ×1
express ×1
jquery ×1
jwt ×1
vue.js ×1