Jquery.load()
может быть загружена только .html
страница, я пытался некоторыми способами загрузить mustache
шаблон в electron
:
(1) npm установить усы и jquery для загрузки
npm install jquery
npm install mustabhe
index.html:
<script>
window.$ = window.jQuery = require('jquery');
window.popper = require("popper.js");
</script>
<script src="./node_modules/mustache/mustache.min.js"></script>
загрузка шаблона item.html
в #view
на другой html-странице:
var viewData = { name: 'Jonny' };
$.get('item.html', function(templates) {
$('#view').append(Mustache.render(templates, viewData));
});
получитьсообщение об ошибке Uncaught SyntaxError: Identifier 'ipcRenderer' has already been declared...
(2) использование jquery-усы
нужно jquery, jquery-усы, усы
index.html:
<script>
window.$ = window.jQuery = require('jquery');
window.popper = require("popper.js");
</script>
<script type="text/plain" src="https://raw.github.com/jonnyreeves/jquery-Mustache/master/jquery.mustache.js"></script>
<script src="./node_modules/mustache/mustache.min.js"></script>
загрузка шаблона item.html
в #view
на другой html-странице:
var viewData = { name: 'Jonny' };
$('#cycle-view').mustache('addindex', viewData, { method: 'html' });
получить сообщение об ошибке
Uncaught TypeError: $(...).mustache is not a function
at HTMLDivElement....
(3) использовать электронные рули Это можно загрузить в mainWindow
, я загрузил больше страниц, пусть это будет компонент.