小编Bal*_*i M的帖子

脚本资源位于重定向后面,这是不允许的 - Service Worker

我在我的Angular应用程序中使用 Service Worker,并且在我的本地主机中一切正常。但是当我尝试推送此代码并将其部署到开发/差异环境中时,出现以下错误

Service worker registration failed: SecurityError: Failed to register a ServiceWorker for scope ('https://a.b.czoo.org/') with script ('https://a.b.czoo.org/sw.js'): 
The script resource is behind a redirect, which is disallowed.
Run Code Online (Sandbox Code Playgroud)

注意:提到的 URL ( https://abczoo.org/ ) 是根域格式。(刚刚在相应位置添加了 a、b 和 czoo)。我的代码部署在自定义分支上,最终 URL 将类似于“https://abczoo.org/AB-123”,其中 AB-123 是我的分支名称。

(更多上下文...)

我在我的服务工作者文件中使用打字稿。该文件将位于不同的位置,在构建过程中,Webpack 使用ts-loader和转换该文件worker-loader,并将该文件放入将在文件中引用的应用程序根文件夹中src/app.component.ts。像这样,

应用程序组件.ts

navigator.serviceWorker.register('/sw.js', { scope: '/' }).then(
  (): void => {
    console.log('Service worker registered');
  },
  (error): void => {
    console.error(`Service worker registration failed: ${error}`);
  },
);
Run Code Online (Sandbox Code Playgroud)

该服务工作线程文件是通过entry …

typescript webpack service-worker angular

6
推荐指数
1
解决办法
1034
查看次数

Draft-js-plugins 中的自定义内联工具栏不起作用

自定义内联工具栏,如其文档中所述,未按预期工作。即使添加了自定义按钮,它也会继续显示默认的内联工具栏。

我的代码如下。

import Editor from "draft-js-plugins-editor";
import createInlineToolbarPlugin from "draft-js-inline-toolbar-plugin";
import { ItalicButton, BoldButton, UnderlineButton } from "draft-js-buttons";
import "draft-js-inline-toolbar-plugin/lib/plugin.css";
import createLinkPlugin from "draft-js-anchor-plugin";

const linkPlugin = createLinkPlugin(); // Adding link button.

const inlineToolbarPlugin = createInlineToolbarPlugin(
    BoldButton,
    ItalicButton,
    UnderlineButton,
    linkPlugin.LinkButton
);

const { InlineToolbar } = inlineToolbarPlugin;

<Editor
    editorState={this.state.editorState}
    onChange={this.onChange}
    plugins={plugins}
    ref={element => {
        this.editor = element;
    }}
/>
<InlineToolbar />
Run Code Online (Sandbox Code Playgroud)

版本如下。

  • “反应”:“^ 16.4.1”
  • Draft-js-plugins-editor": "^2.1.1"

提前致谢。

reactjs draftjs draft-js-plugins

5
推荐指数
1
解决办法
2657
查看次数

在Windows Phone 8.1中切换手电筒

谁能说如何使用C#在Windows Phone 8.1中切换手电筒?似乎Windows Phone 8.1中有许多API更改,并且不支持WP 8.0中的大多数API.答案非常感谢.

c# windows-phone-8.1

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

为什么修改选项时,React Select 中的下拉菜单中的箭头键导航不起作用(或无法聚焦)?

我一直在使用 React Select,我只是想知道为什么当我尝试修改下拉列表中的选项时箭头键导航不起作用。

我的实现如下。

<Select
    styles={_customStyles}
    isClearable={false}
    isSearchable={true}
    options={sitesOptions}
    onChange={handleChange}
    value={selectedOption}
    menuIsOpen={true}
/>
Run Code Online (Sandbox Code Playgroud)

_customStyles如下

const _customStyles = {
        control: (base, state) => ({
            ...base,
            boxShadow: 'none',
            minWidth: '242px',
            zIndex: 9999,
            border: '1px solid lightgray', // default border color
            '&:hover': { borderColor: 'gray' } // border style on hover
        }),
        option: (provided, state) => ({
            ...provided,
            backgroundColor: state.isSelected ? '#d46514' : 'transparent',
            ':focus, :hover, :active, :visited': {
                backgroundColor: state.isSelected ? '#d46514' : '#5a61691a'
            }
        })
    };
Run Code Online (Sandbox Code Playgroud)

如果我从 _customStyles 中删除选项对象,我就可以浏览下拉列表中的列表。换句话说,我可以导航,但它是透明的。我不知道当前选择的项目,但当我点击“Enter”时,该选项被选中。

为什么背景颜色没有应用于元素?它是透明的。当我删除选项时,将应用默认颜色并且工作正常。 …

reactjs react-select

2
推荐指数
1
解决办法
9854
查看次数