Selaa lähdekoodia

added whatwg-fetch dependency

jason.lu 6 vuotta sitten
vanhempi
commit
ccb051241e

+ 2 - 1
sourcecode/h5app/vue/package.json

@@ -11,7 +11,8 @@
     "vant": "^1.4.8",
     "vue": "^2.5.17",
     "vue-clipboard2": "^0.2.1",
-    "vue-router": "^3.0.2"
+    "vue-router": "^3.0.2",
+    "whatwg-fetch": "^3.0.0"
   },
   "devDependencies": {
     "@vue/cli-plugin-babel": "^3.2.0",

+ 4 - 2
sourcecode/h5app/vue/src/connector/simple-demo.js

@@ -66,6 +66,7 @@ function js_load_something(){
  //
  *****************************************************************************/
 
+//Module means some component (need only to draw);
 var test_vue_module = new Module("nothing", "smartUsers");
 test_vue_module.drawData = function (data) {
     test_vue_app.data.userlist.pop();
@@ -76,7 +77,8 @@ test_vue_module.drawData = function (data) {
 
 var loader = new (function(){
 
-    this.userListServ = new DataObjectService("smartUsers", AUTO, "");
+    /* this is the main data service that is auto-updating your data*/
+    this.userListServ = new DataObjectService("smartUsers", AUTO, "?ext=1");
 
     // Optional for setting up self-defined interval
     // this.userListServ.autoInterval = 300;
@@ -94,7 +96,7 @@ var loader = new (function(){
      * loadOften : to auto-load some data
      */
     this.loadOften = function(){
-        // Intervals
+        // Binding Intervals to DataService
         this.userListServ.bind(function (data) {
             // auto call
             test_vue_module.setData(data);

+ 18 - 0
sourcecode/h5app/vue/src/views/login.vue

@@ -27,6 +27,7 @@
 </template>
 
 <script>
+    import 'whatwg-fetch';
     import {
         Field,
         CellGroup,
@@ -56,6 +57,23 @@
             }
         }
     }
+
+    /** Post JSON **/
+    /*
+    // 怎么把一段放到另一个文件?
+
+    fetch('/users', {
+        method: 'POST',
+        headers: {
+            'Content-Type': 'application/json'
+        },
+        body: JSON.stringify({
+            name: 'Hubot',
+            login: 'hubot',
+        })
+    })
+
+    */
 </script>
 
 <style scoped>