小编Iva*_*žić的帖子

如何使用mysljs批量插入mySql和node.js

我无法使用node.js lib mysljs在我的数据库中使用批量插入.

我按照以下答案:

如何使用node.js在mySQL中进行批量插入

没有成功.

var sql = "INSERT INTO resources (resource_container_id, name, title, extension, mime_type, size) VALUES ?";

var values = [
  [1, 'pic1', 'title1', '.png', 'image/png', 500], 
  [1, 'pic2', 'title2', '.png', 'image/png', 700]];

return connection.query(sql, [values], (result) => {
    if (err) throw err;
    connection.end();
});
Run Code Online (Sandbox Code Playgroud)

我一直收到错误:

 'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'?\' at line 1' 
Run Code Online (Sandbox Code Playgroud)

我也尝试使用蓝鸟宣传查询方法,但没有成功,我再次得到同样的错误.

mysql node.js bluebird

8
推荐指数
1
解决办法
709
查看次数

固定元素的分页符

使用CSS规则page-break,@media print当我们从浏览器打印时,很容易破坏内容.除了一件事,它对我有用:当元素被修复时它不起作用.使用page-break-after: alwayspage-break-before: always在固定元素上没有帮助,结果总是相同的 - 内容只是重叠div.这有什么解决方案吗?

<div id="content">   
</div>

<div class="footer"></div>
Run Code Online (Sandbox Code Playgroud)

内容出现在内容div中,并且是动态的.页脚CSS:

@media screen{
  .footer{
    display:none;
  }
}

.footer{
  display:block;
  height:30px;
  position:fixed;
  bottom:0;
}
Run Code Online (Sandbox Code Playgroud)

使用这个CSS页脚出现在每个页面上,但page-break.footer课堂上使用不会破坏页面?

html css

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

获取事件未接收请求标头

似乎服务工作者内部的fetch事件没有收到请求头,尽管在MDN文档中有说明:

您可以通过调用FetchEvent返回的Request对象的参数来检索有关每个请求的大量信息:

event.request.url
event.request.method
event.request.headers
event.request.body

从主线程获取资源的代码:

fetch(`${companyConfig.base}ticket-scanner/config`, {
    headers: {
        'X-Nsft-Locale' : `en`,
        'X-Nsft-Id': `1`,
    },
}).then((response) => {
    return response.json();
}).then((data) => {...})
Run Code Online (Sandbox Code Playgroud)

在SW文件中获取事件处理程序:

self.addEventListener('fetch', function(event) {
  event.respondWith(
    caches.match(event.request, {cacheName : CACHE_NAME})
        .then(function(response) {
            if(response) {
                return response;
            }
            console.log(event.request.headers); //Log out headers
            return fetch(event.request).then(function(response){
                return response;
            }).catch(function(err){
                console.error(err);
            })
        })
    )
});
Run Code Online (Sandbox Code Playgroud)

每个fetch事件的日志标题都会给我一个空对象:

标题{}

这阻止我缓存此特定请求,该请求仅需要这两个标头.证书不是必需的.我错过了什么吗?

javascript service-worker service-worker-events

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

使用Core模块中的组件

我是Angular2的新手,我在使用im(ex)移植模块时遇到了一些困难.

根据官方风格指南,CoreModule是:

CoreModule - 在应用程序启动时导入一次,从不在其他地方导入.

这是否意味着所有那些从Core模块导出的东西只能在只导入它的模块中使用?在某些子模块中没有办法提供这些东西吗?我创建了虚拟项目来测试这种行为:

虚拟组件:

@Component({
  selector: 'dummy-component',
  template: '<h4>Dummy component</h4>',
})
export class DummyComponent {}
Run Code Online (Sandbox Code Playgroud)

核心模块:

import { DummyComponent } from './dummy.component';

@NgModule({
  declarations : [DummyComponent],
  exports : [DummyComponent]
})

export class CoreModule {}
Run Code Online (Sandbox Code Playgroud)

App模块(根模块):

@NgModule({
  declarations: [AppComponent,],
  imports: [BrowserModule, CoreModule, HomeModule, RoutingModule],
  exports : [CoreModule],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)

Home模块声明home组件:

@Component({
  selector: 'home-component',
  template: 
  `
    <h2>Home component</h2>
    <dummy-component></dummy-component>
  `
})
export class HomeComponent {}
Run Code Online (Sandbox Code Playgroud)

当我尝试运行此代码时出现此错误:

'dummy-component' is not a known …
Run Code Online (Sandbox Code Playgroud)

angular

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