因此,目前我已经制作了2张包含信息的表格。但是我想这样做,以便当用户打开html文档时它只显示1个表,并且您可以在不同的表之间切换。当我单击表1的按钮时,它隐藏了表2,而当我单击表2的按钮时,它隐藏了表1。
function myFunction() {
var x = document.getElementById("Tables");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
function myFunction1() {
var x = document.getElementById("Tables1");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}Run Code Online (Sandbox Code Playgroud)
#Tables {
width: 100%;
padding: 50px 0;
text-align: center;
background-color: blue;
margin-top: 20px;
}
#Tables1 {
width: 100%;
padding: 50px 0;
text-align: center;
background-color: Purple;
margin-top: 20px;
}
table {
font-family: arial, sans-serif; …Run Code Online (Sandbox Code Playgroud)我希望能够跟踪应用程序中某些功能的用户位置,但我希望用户能够根据需要关闭位置。我一直用来expo-location查找用户位置、请求权限和各种其他事情。但是当我使用 watchPositionAsync 时,当用户关闭该功能时我无法将其删除。我阅读了文档,它说我可以使用remove(),但当我尝试这样做时出现以下错误:
Unhandled promise rejection: TypeError: client.location.remove is not a function. (In 'client.location.remove()', 'client.location.remove' is undefined)
作为参考,客户端只是一个全局对象,它为用户存储一些设置(这样我就不必一遍又一遍地获取它)。
客户端.js
let client = {
user: {},
location: null
};
Run Code Online (Sandbox Code Playgroud)
跟踪.js
import * as Location from 'expo-location';
export async function startTracking(client){
console.log('Starting tracking')
if(!client.location){
client.location = Location.watchPositionAsync({
accuracy: Location.Accuracy.Highest,
distanceInterval: 1,
timeInterval: 5000,
}, (loc) => {
console.log(loc)
});
}
}
export async function stopTracking(client){
console.log('Remove tracking')
await client.location.remove();
}
Run Code Online (Sandbox Code Playgroud)
更多信息: