Electron是一個使用JavaScript、HTML和CSS構建跨平臺桌面應用程序的框架。 您能夠將Electron與純JavaScript或您選擇的JavaScript框架一塊兒使用:javascript
要建立基本的Electron應用程序,請按照下列步驟操做:css
git clone https://github.com/electron/electron-quick-start
cd electron-quick-start
npm install
npm start
複製代碼
您應該看到以下所示的Hello World應用程序:html
要將WijmoJS添加到應用程序,請先安裝它。在命令提示符下,進入app文件夾(electron-quick-start)並鍵入:前端
npm install Wijmo
複製代碼
接下來,使用VS Code或您喜愛的編輯器打開index.html文件,並添加如下內容:vue
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<!-- add Bootstrap and Wijmo css -->
<link href=https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css rel="stylesheet"/>
<link href=https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css rel="stylesheet"/>
<!-- define the app styles -->
<style> .app-panel { margin: 0 48pt; } .app-panel .wj-control { display: inline-block; vertical-align: top; width: 400px; height: 300px; } </style>
</head>
<body>
<div class="container">
<h1>Hello World!</h1>
<p>
<!-- Node.js APIs are available in this renderer process. -->
We are using Node.js
<script>document.write(process.versions.node)</script>,
Chromium <script>document.write(process.versions.chrome)</script>,
and Electron
<script>document.write(process.versions.electron)</script>.
</p>
<!--add Wijmo controls to the page -->
<div class="app-panel">
<div id="theGrid"></div>
<div id="theChart"></div>
</div>
</div>
<script> // You can also require other files to run in this process require('./renderer.js') </script>
</body>
</html>
複製代碼
在這一步中,咱們爲兩個WijmoJS控件添加了一些樣式和主題元素。接下來,打開「renderer.js」文件並按以下所示進行編輯:java
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
// import Wijmo
var wjCore = require('./node_modules/wijmo/wijmo.js');
var wjGrid = require('./node_modules/wijmo/wijmo.grid.js');
var wjChart = require('./node_modules/wijmo/wijmo.chart.js');
// set the Wijmo license key
var key = 'GrapeCity-Internal-Use-Only,…';
wjCore.setLicenseKey(key);
// create the controls
var theGrid = new wjGrid.FlexGrid('#theGrid', {
itemsSource: getData()
});
var theChart = new wjChart.FlexChart('#theChart', {
itemsSource: theGrid.itemsSource,
bindingX: 'country',
series: [
{ name: 'Sales', binding: 'sales' },
{ name: 'Expenses', binding: 'expenses' },
{ name: 'Downloads', binding: 'downloads' },
]
});
// get some random data
function getData() {
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
data = [];
for (var i = 0; i < countries.length; i++) {
data.push({
country: countries[i],
sales: Math.random() * 10000,
expenses: Math.random() * 5000,
downloads: Math.round(Math.random() * 20000),
});
}
return new wjCore.CollectionView(data);
}
複製代碼
實現這段代碼首先須要三個WijmoJS模塊:WijmoJS Core,Grid和Chart。 (它設置了WijmoJS許可證密鑰,所以應用程序在運行時不會顯示水印。若是您沒有許可證密鑰,請跳過此步驟,應用程序仍將運行,但會顯示水印元素)node
若是您在此以前已經安裝了許可證密鑰,則不須要特定域。WijmoJS電子應用程序會從文件或本地主機協議運行,所以任何有效的WijmoJS密鑰都將起做用,不管用於生成它的域是什麼。react
最後一步是建立WijmoJS控件並將它們綁定到數據源。 在此示例中,網格和圖表綁定到同一數據源。git
像之前同樣運行應用程序!github
npm start
複製代碼
此次你會看到這個:
因爲表格和圖表綁定到相同的數據,所以您對網格所作的任何更改(如編輯單元格或排序列)都將自動應用於圖表。
如今,請下載WijmoJS,享用WijmoJS JavaScript控件的Electron應用程序吧。
快如閃電,觸控優先。純前端控件集 WijmoJS,爲您的企業應用提供更加靈活的操做體驗,在全球率先支持 AngularJS,並提供性能卓越、零依賴的 FlexGrid 和金融圖表等多個控件,爲您提供易用、輕鬆的操做體驗,全面知足開發所需。