正如标题所说,我想问一下在 Angular Firestore 中执行查询时 get() 和 valueChanges() 之间有什么区别(如果有的话)。
在读取/成本方面,两者之间是否也有任何优点/缺点?
javascript firebase typescript angular google-cloud-firestore
我在用
window.addEventListener('devicemotion', event => this.watchDeviceMotion(event))
watchDeviceMotion(event: any) {
let motionData = {
x: event.acceleration.x,
y: event.acceleration.y,
z: event.acceleration.z,
}
let rotationData = {
alpha: event.rotationRate.alpha,
beta: event.rotationRate.beta,
gamma: event.rotationRate.gamma
}
if (this.getSensorData) {
// console.log(JSON.stringify(motionData))
// console.log(JSON.stringify(rotationData))
this.userData.motionData.push(motionData)
this.userData.rotationData.push(rotationData)
}
}
Run Code Online (Sandbox Code Playgroud)
使用带有 Angular 的 Ionic 访问 Android 设备上的加速度计数据。在应用程序内部时,事件以 60 Hz 的频率运行,但当应用程序切换到后台时,频率在前 5 分钟内下降约 9-10 Hz,并且在某个时刻仍处于后台时,它会以 60 Hz 的频率返回并且无限期地保持这样。
我也在使用后台插件
this.backgroundMode.enable();
this.backgroundMode.on('activate').subscribe(() => {
this.backgroundMode.disableWebViewOptimizations();
});
Run Code Online (Sandbox Code Playgroud)
我尝试将 disableBatteryOptimizations() 添加到具有 config.xml 中相应条件的后台插件,但仍然没有运气。
我还尝试了 Device Motion 和 Gyroscope 的插件,但它们的行为相同。
我应该如何防止频率变慢?有没有其他人遇到过这个问题?
我正在创建一个用于文本识别的管道,我想使用 Tensorflow Dtatasets 通过 OpenCV 的一些预处理来加载数据
我正在关注本教程 https://www.tensorflow.org/guide/datasets#applying_centric_python_logic_with_tfpy_func 并且我有这个预处理函数:
def preprocess(path, imgSize=(1024, 64), dataAugmentation=False):
img = cv2.imread(path, cv2.IMREAD_GRAYSCALE)
kernel = np.ones((3, 3), np.uint8)
th, img = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY_INV +
cv2.THRESH_OTSU)
img = cv2.dilate(img, kernel, iterations=1)
# create target image and copy sample image into it
(wt, ht) = imgSize
(h, w) = img.shape
fx = w / wt
fy = h / ht
f = max(fx, fy)
newSize = (max(min(wt, int(w / f)), 1),
max(min(ht, int(h / f)), …Run Code Online (Sandbox Code Playgroud) 我在 Angular 的 index.html 中创建了一个加载屏幕,例如:
<app-root>
<div class="app-loading">
<svg class="logo" viewBox="0 0 100 100" >
</svg>
</div>
</app-root>
Run Code Online (Sandbox Code Playgroud)
并应用了一些风格。但是在页面加载后,svg 突然消失了。
<style type="text/css">
body, html {
height: 100%;
}
.app-loading {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
}
.app-loading .logo {
height: 100px;
width: 100px;
transform-origin: center center;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
</style>
Run Code Online (Sandbox Code Playgroud)
当它消失时,我如何进行和缓出过渡?
我有一个 SVG 元素,我想在 Angular 中的某个时刻添加一个 matTooltip。我观察到,如果我尝试像这样添加 matTooltip:
generate() {
var svgEle = document.getElementById("testSVG");
var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
rect.setAttribute('id', "rect");
rect.setAttribute('x', "73");
rect.setAttribute('y', "95");
rect.setAttribute('class', "st01");
rect.setAttribute('width', "407");
rect.setAttribute('height', "328");
rect.setAttribute('matTooltip', "Info about the action");
svgEle.append(rect)
}
Run Code Online (Sandbox Code Playgroud)
使用html测试代码:
<div style="width:400px">
<svg version="1.1" id="testSVG" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 1000 1000" style="enable-background:new 0 0 1000 1000;"
xml:space="preserve">
<style type="text/css">
.st01{fill:#F99191;}
.st11{fill:#92B1F7;}
</style>
<rect x="638.5" y="146" class="st11" width="236" height="219"
matTooltip="Info about the action"/>
</svg>
</div>
<button mat-stroked-button (click)="generate()">Generate</button>
Run Code Online (Sandbox Code Playgroud)
它不起作用。
这种情况下到底是什么问题呢?
我正在尝试使用 Materialize CSS 将输入文本居中,但“center”和“center-align”类似乎没有效果。我不知道我在这里错过了什么
<div class="section">
<div class="row center-align">
<div class="input-field col s3 center-align">
<input id="email" type="email" class="validate">
<label for="email">Email</label>
</div>
</div>
<div class="row">
<div class="input-field col s3 center-align">
<input id="password" type="password" class="validate">
<label for="password">Password</label>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 与标题相同,在tf.keras.layers.Embedding中,为什么重要的是要知道字典的大小作为输入维?
我正在使用 Firebase 的实时数据库来实时更新图表内的值。但是,我不知道如何仅检索添加到数据库的最后一个值。
我在limitToLast 和 'child_added' do not work Together #1773中找到了一些解释,但我没有设法让它工作。
到目前为止,我设法做到了这一点:
this.items = db.list('/items').valueChanges()
this.items.forEach(item => {
this.data = item;
this.add(this.data[this.data.length-1])
console.log(this.data)
})
add(point: any) {
this.chart.addPoint(point)
}
Run Code Online (Sandbox Code Playgroud)
但我知道这根本没有效率。
firebase typescript firebase-realtime-database angularfire2 angular
angular ×5
css ×2
firebase ×2
tensorflow ×2
typescript ×2
android ×1
angularfire2 ×1
devicemotion ×1
html ×1
ionic4 ×1
javascript ×1
opencv ×1
python ×1
svg ×1
tooltip ×1