在webpack.config.js确定模块中,我们可以使用 3 个不同的属性:
...
module:{
rules: [
{
test: ... // the first one, commonly used in most example we can found on internet
include: ... // the second one
resource: ... // the third one
use: ['style-loader','css-loader'],
},
...
],
...
}
Run Code Online (Sandbox Code Playgroud)
文档没有解释它们:
Rule.test
包括所有通过测试断言的模块。如果您提供一个Rule.test选项,则不能同时提供Rule.resource. 详情请参阅Rule.resource和Condition.test
Rule.include
包含与任何这些条件匹配的所有模块。如果您提供一个Rule.include选项,则不能同时提供Rule.resource. 详情请参阅Rule.resource和Condition.include
Rule.resource
ACondition与资源匹配。详情请参阅Rule条件。
他们每个人都是Condition类型。其中一些是相互排斥的。但每个的目的是什么?我们什么时候应该使用每一个?
只要有,test一切就都清楚了。
我想在我的网站上使用.avif和.webp来显示图像,请记住我需要为不受支持的浏览器提供后备。文档https://developer.mozilla.org/en-US/docs/Web/CSS/image/image-set()#using_image-set_to_provide_alternative_formats建议-webkit-image-set应该有所帮助:
background-image: url("/public/header-fallback.jpg");
background-image: -webkit-image-set(url('/public/header.avif') type('image/avif'), url('/public/header.webp') type('image/webp'), url('/public/header.jpg') type('image/jpeg'));
Run Code Online (Sandbox Code Playgroud)
这在 Firefox 中有效(avif 被跳过并使用 webp),但 Chrome 给了我Invalid property value(整个样式被忽略并使用“header-fallback.jpg”)。为什么?
我知道使用普通的 Web 开发人员工具(https://developer.mozilla.org/en/docs/Mozilla/Add-ons/WebExtensions/Debugging#Debugging_content_scripts)调试内容脚本,这很完美。debugger关键字按预期工作。
但在这种确切的情况下,事情会被打破:
addon.id = "123-568-485"; // I never define `addon` before this line, so this cause: ReferenceError: "addon is not defined". We aren't aware of this mistake.
// Some more code
// Some more code
// Some more code
// Some more code
debugger; // Here we want to stop execution and inspect, some other stuff. Remember that we aren't aware of earlier mistake.
Run Code Online (Sandbox Code Playgroud)
我们所期望的是,在控制台中Reference error会出现关于错误,但它不会。控制台沉默,我们不知道为什么我们的debugger关键字不起作用。
这种无声错误,发生在我拼错变量名时。结果想不通是怎么回事。
我读 :
我真的很困惑.我应该如何使用node.js中的mongoDB?我是菜鸟,我的问题可能看起来很愚蠢.
var db = new db.MongoClient(new db.Server('localhost', 27017));
db.open(function(err, dataBase) {
//all code here?
dataBase.close();
});
Run Code Online (Sandbox Code Playgroud)
或者每当我需要来自db的东西时我都需要打电话:
MongoClient.connect("mongodb://localhost:27017/myDB", function(err, dataBase) {
//all code here
dataBase.close();
});
Run Code Online (Sandbox Code Playgroud)
打开和连接有什么区别?我在手册中读到了打开:初始化和第二次连接.但究竟是什么意思呢?我假设两者都做同样的事情,但在另一方面,所以什么时候应该使用一个而不是另一个?
我还想问一下mongoClient需要4个套接字是正常的吗?我同时运行了两个myWEbServer,这里是图片:http://i43.tinypic.com/29mlr14.png
编辑:我想提一下这不是问题(相当怀疑:D),我的服务器工作得很完美.我问,因为我想知道我是否正确使用mongoDB驱动程序.现在/实际上我使用第一个选项,init mongo dirver在开头和内部加载放入所有代码.
我正在阅读着名的紫龙书第2版,并且无法从第65页获得关于创建FIRST集的示例:
我们有以下语法(终端加粗):
stmt → expr;
| if(expr)stmt
| for(optexpr; optexpr; optexpr)stmt
| 其他optexpr→ε
| EXPR
书中建议以下是FIRST的正确计算:
FIRST(stmt)→{ expr,if,for,other } //就此达成一致
FIRST(expr;)→{ expr } //这是从哪里来的?
正如评论所暗示的那样,第二行来自哪里?
我刚开始使用 PRISM,遇到一个我无法解决的异常。
<Window x:Class="Workplace.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://www.codeplex.com/prism"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid Name="Header" prism:RegionManager.RegionName="Header">
</Grid>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
.
using Autofac;
using Prism.Autofac;
using Prism.Modularity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace Workplace
{
class Bootstrapper : AutofacBootstrapper
{
protected override DependencyObject CreateShell()
{
return new Shell();
}
protected override void InitializeShell()
{
base.InitializeShell();
Application.Current.MainWindow = (Window) this.Shell;
Application.Current.MainWindow.Show();
}
protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
}
}
}
Run Code Online (Sandbox Code Playgroud)
运行后我得到异常:
KeyNotFoundException:未在区域适配器映射中注册 System.Windows.Controls.Grid …
这是一个为控制win32 api中的消息而发布的理论问题。
WM_COMMAND和 和有WM_NOTIFY什么区别?我们什么时候需要处理这些消息,什么时候选择忽略它们?
产生这种疑问是因为这两个消息都是在用户与控件交互时发送的,并且都将相同的信息发送到事件类型的窗口过程,控件 Id 和控件句柄作为结构(LPNMHDR 在情况下WM_NOTIFY)或直接发送(LPARAM 句柄来控制和 LOWORD (WPARAM) 的情况下WM_COMMAND)
有了所有这些相似之处,为什么我们仍然将两者一起使用,而不仅仅是弃用一个?