Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Can';t将虚拟键盘jQuery插件与Angular 4+;网页包_Javascript_Jquery_Angular_Webpack_Asp.net Core - Fatal编程技术网

Javascript Can';t将虚拟键盘jQuery插件与Angular 4+;网页包

Javascript Can';t将虚拟键盘jQuery插件与Angular 4+;网页包,javascript,jquery,angular,webpack,asp.net-core,Javascript,Jquery,Angular,Webpack,Asp.net Core,我正在尝试使用Asp核心+网页包中Angular 4模板上的虚拟键盘 我已经安装了npm安装--保存dev@types/虚拟键盘 在webpack.config.vendor.js中,我写了这行: const treeShakableModules = [ ..... 'virtual-keyboard', ... ]; 在我的组件模板中: <input id="mycontrol" type="text"> 在控制台中并没有错误,但在文本框中并没有显示键盘

我正在尝试使用Asp核心+网页包中Angular 4模板上的虚拟键盘 我已经安装了npm安装--保存dev@types/虚拟键盘 在webpack.config.vendor.js中,我写了这行:

const treeShakableModules = [
    .....
    'virtual-keyboard',
   ...
];
在我的组件模板中:

<input id="mycontrol" type="text">
在控制台中并没有错误,但在文本框中并没有显示键盘 我想webpack.config.vendor.js中一定有东西要放


感谢您通过npm安装jquery和虚拟键盘。试试这个:

// In *.ts file:
import * as $ from 'jquery';
import 'virtual-keyboard';

$('.vk').keyboard({
  change: (e, keyboard, el) => {
    // Dispatch input event to notify angular about changes
    const inputEvent: any = document.createEvent('CustomEvent');
    inputEvent.initEvent('input', true, true);
    el.dispatchEvent(inputEvent);
  }
});
//在scss中:

@import "../../node_modules/virtual-keyboard/dist/css/keyboard-dark.min";

顺便说一句,为了能够订阅虚拟键盘事件,最好在那里创建指令并初始化键盘。

您也可以安装键盘插件,github页面中有说明:。然后简单地要求它。有了webpack provideplugin,你也不应该通过cdnHi使用jquery。我已经使用npm安装了插件,它在node_模块中,但我不知道如何从那里使用它。我已经将文件复制到wwwroot。谢谢,你不需要它吗?其他模块的使用情况如何?您好。我只举了一些例子来说明如何将它与jQuery一起使用,而不是与typescriptI一起使用。我可以这样使用:从“虚拟键盘”导入{};但是…如何显示键盘,我只有jQuery示例:$('#mycontrol')).keyboard();
// In *.ts file:
import * as $ from 'jquery';
import 'virtual-keyboard';

$('.vk').keyboard({
  change: (e, keyboard, el) => {
    // Dispatch input event to notify angular about changes
    const inputEvent: any = document.createEvent('CustomEvent');
    inputEvent.initEvent('input', true, true);
    el.dispatchEvent(inputEvent);
  }
});
@import "../../node_modules/virtual-keyboard/dist/css/keyboard-dark.min";