我在youtube上直播了很多,从昨天起我经历了一个奇怪的事情:
我在我的网站中嵌入了直播网址.它是youtube.com/embed/ABCDE(正常的嵌入链接).该链接用于显示当前直播而非特定视频.例如:
我正在播放,你可以观看它youtube.com/embed/ABCDE.当我完成后,视频会获得自己的网址,例如youtube.com/watch?v=FGHIJ.在下一次我将流,用户可以观看流youtube.com/embed/ABCDE(这是一个没有改变的永久网址).
现在,每次流式传输时,直播都会在第一时间获得自己的链接,这意味着每次流式传输时都必须手动更新我的嵌入代码.
我对Google,SO和YouTube进行了一些研究,我发现直播的永久网址是youtube.com/channel/CHANNEL_ID/live.它太棒了,但是我找不到嵌入它的方法.
(我使用wordpress,我没有找到任何插件自动为我做).
TL:DR; 如何在页面中嵌入直播youtube.com/channel/CHANNEL_ID/live?
在我的项目中,我使用带有 Less 的 CSS 模块,这意味着我可以两全其美。
我的src文件夹看起来像这样:
components/
[all components]
theme/
themes/
lightTheme.less
darkTheme.less
palette.less
Run Code Online (Sandbox Code Playgroud)
调色板.less:
components/
[all components]
theme/
themes/
lightTheme.less
darkTheme.less
palette.less
Run Code Online (Sandbox Code Playgroud)
然后,在每个想要使用主题颜色的组件中,我这样做:
组件.module.less :
@import './themes/lightTheme.less';
Run Code Online (Sandbox Code Playgroud)
这种结构让我可以编辑palette.less以导入我想要使用的主题。问题是我想让用户自己选择他们喜欢的主题。主题应该可以在运行时切换,这意味着我需要以某种方式编译两个主题。
我想象完美的解决方案是这样的:
无应用程序
@import '../../theme/palette.less';
.element {
background-color: @primary;
}
Run Code Online (Sandbox Code Playgroud)
然后以某种方式@theme在每个组件中导入这个变量并从中读取属性(即@theme[primary])。
不幸的是,Less 变量范围不是这样工作的。
我对任何使用 Less 模块的解决方案持开放态度。
谢谢!
考虑以下示例:
class A {}
class B extends A {
foo() {
return 6;
}
}
const variable: A = new B();
const isValid = variable instanceof B;
if (isValid) {
variable.foo();
}
Run Code Online (Sandbox Code Playgroud)
调用.foo()时提示如下错误:
这是有道理的,因为variable它的类型是A。但仅当是 的实例variable.foo()时才会运行。variableB
这样做时不会出现此问题:
class A {}
class B extends A {
foo() {
return 6;
}
}
const variable: A = new B();
if (variable instanceof B) {
variable.foo();
}
Run Code Online (Sandbox Code Playgroud)
为什么条件存储在变量中而不是显式写入变量中很重要if?
在我的 Express 项目中,我从@common/foo. 感谢pathsin tsconfig.json,它只是../common/src/foo. 这很棒,并且可以使用以下脚本进行开发nodemon.json:
{
"watch": ["src", "../common/src"],
"ext": "ts",
"ignore": ["src/public"],
"exec": "ts-node -r tsconfig-paths/register src/index.ts"
}
Run Code Online (Sandbox Code Playgroud)
问题是我不能让它在生产模式下工作。
我使用 构建项目tsc,如果我检查生成的文件,它们会从@common/而不是从导入内容../common/src/。起初我认为这很好,因为tsconfig-paths在运行时工作,所以我只需要将它包含在start脚本中:
node -r tsconfig-paths/register dist/index.js
Run Code Online (Sandbox Code Playgroud)
不幸的是它不起作用,我Cannot find module '@common/foo在控制台中收到了这些错误消息。
有什么问题?我配置错了吗?
我的package.json(删除了所有不相关的部分):
{
"main": "index.js",
"scripts": {
"start": "cross-env NODE_ENV=prod node dist/index.js",
"build": "rimraf ./dist/ && cross-env NODE_ENV=prod tsc"
},
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法将字符串1 hello there 6 foo 37 bar转换成数组,如:
Array ( [1] => "hello there",
[6] => "foo",
[37] => "bar" )
Run Code Online (Sandbox Code Playgroud)
每个数字都是它后面的字符串的索引.我想得到它的帮助.谢谢!:)