小编Owe*_*n M的帖子

如何防止"play()请求被暂停()调用中断"错误?

我创建了一个网站,如果用户点击,它会发出声音.为了防止声音重叠,我不得不添加代码:

n.pause();
n.currentTime = 0;
n.play();
Run Code Online (Sandbox Code Playgroud)

但这会导致错误: The play() request was interrupted by a call to pause()
每次在另一次触发后立即触发声音事件时出现.声音仍然很好,但我想防止这个错误信息不断弹出.有任何想法吗?

提前致谢!

html javascript audio google-chrome

102
推荐指数
5
解决办法
13万
查看次数

VSCode调试器弄乱了相对路径

所以我试图运行VSCode调试器运行我的express程序,但是我注意到它弄乱了相对目录路径。

当使用诸如JIMPNode图像操纵器之类的模块时,当我从Powershell运行应用程序时,我需要输入相对于项目根目录的路径(“ package.JSONis” 所在的位置)以查找图像。但是,当我从VSCode调试器运行它时,出现一个错误,因为它正在查找相对于我的app目录的图像,该目录是我的项目根目录中的一个文件夹。

有可以修改的配置可以解决此问题吗?

launch.json

{
    // Use IntelliSense to learn about possible Node.js debug attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "npm start",
            "program": "${workspaceRoot}/app/app.js"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

jsconfig.js

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "allowSyntheticDefaultImports": true
    },
    "exclude": [
        "node_modules"
    ]
}
Run Code Online (Sandbox Code Playgroud)

提前致谢

javascript debugging npm visual-studio-code

4
推荐指数
1
解决办法
1068
查看次数

如何从TestCafe中的window对象获取构造函数?

在我的testcafe测试中,我需要获取我正在使用的库的构造函数,以便对其调用静态方法。

但是,我无法使用给定的ClientFunction和Eval方法来执行此操作。我该如何获取构造函数?

我尝试了以下方法:

// Does not work, because the docs say it only allows using ClientFunction for obtaining "serializable" values

let getSortable = new ClientFunction(() => window.Sortable);
test('test', async t => {
    let Sortable = await getSortable();
    console.log(Sortable); // Logs undefined
});
Run Code Online (Sandbox Code Playgroud)
test('test', async t => {
    let Sortable = await t.eval(() => window.Sortable);
    console.log(Sortable); // Logs undefined (not sure why)
});
Run Code Online (Sandbox Code Playgroud)

javascript automated-tests web-testing e2e-testing testcafe

4
推荐指数
1
解决办法
81
查看次数

如何在彼此内部导入两个 VueJS 组件?

我有两个组件,一个item组件和一个folder组件。每个都item包含它自己的folder组件,每个folder组件都包含一个 s 列表item

因此,我尝试在组件item中使用该组件folder,反之亦然,但是,我收到错误:unknown custom element: <item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.尽管我name在两个组件上都设置了选项。有任何想法吗?

代码如下

item.vue

<template>
    <div class="item" style="height: 30px">
        . . .
        <folder v-if="item.hasChildren" :id="id"></folder>
    </div>
</template>


<script scoped>
import Folder from './folder.vue';

export default {
    name: 'item',
    props: ['id'],
    components: {
        Folder
    }
};

</script>
Run Code Online (Sandbox Code Playgroud)

folder.vue

<template> …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js

3
推荐指数
1
解决办法
1184
查看次数