Giter VIP home page Giter VIP logo

Comments (3)

lizhangqu avatar lizhangqu commented on May 6, 2024

i find http://172.18.23.41:12580/examples/build/index.js is

{"transformerVersion":"0.3.0"}

but the file in assets is

{"transformerVersion":"0.1.8"}

I replace the content with the file in assets,it run .
But I use the content which is generated. it doesn't run.

from weex.

bsed avatar bsed commented on May 6, 2024

@lizhangqu i don't can visit this link http://172.18.23.41:12580/examples/build/index.js

from weex.

lizhangqu avatar lizhangqu commented on May 6, 2024

@D0f 172.18.23.41 is my PC ip,you can't visit,but my android phone can visit it. the content in the link is

define('@weex-component/ui-list-item', function (require, exports, module) {

;
  module.exports = {
    data: function () {return {
      bgColor: '#ffffff',
      click: function() {
      }
    }},
    methods: {
      touchstart: function() {
        // TODO adaptive opposite bgColor
//        this.bgColor = '#e6e6e6';
      },
      touchend: function() {
//        this.bgColor = '#ffffff';
      }
    }
  }


;module.exports.style = {
  "item": {
    "paddingTop": 25,
    "paddingBottom": 25,
    "paddingLeft": 35,
    "paddingRight": 35,
    "height": 160,
    "justifyContent": "center",
    "borderBottomWidth": 1,
    "borderColor": "#dddddd"
  }
}

;module.exports.template = {
  "type": "div",
  "classList": [
    "item"
  ],
  "events": {
    "click": "click",
    "touchstart": "touchstart",
    "touchend": "touchend"
  },
  "style": {
    "backgroundColor": function () {return this.bgColor}
  },
  "children": [
    {
      "type": "content"
    }
  ]
}

;})

// module

define('@weex-component/indexitem', function (require, exports, module) {

;
  module.exports = {
    data: function () {return {
      title: '',
      url: ''
    }},
    methods: {
      redirect: function() {
        this.$openURL(this.url);
      }
    }
  }


;module.exports.style = {
  "item-txt": {
    "fontSize": 48,
    "color": "#555555"
  }
}

;module.exports.template = {
  "type": "ui-list-item",
  "attr": {
    "click": function () {return this.redirect}
  },
  "children": [
    {
      "type": "text",
      "classList": [
        "item-txt"
      ],
      "attr": {
        "value": function () {return this.title}
      }
    }
  ]
}

;})

// module

define('@weex-component/index', function (require, exports, module) {

;
  module.exports = {
    data: function () {return {
      cases: [
        {name: 'hello', title: 'Hello World'},
        {name: 'textDemo', title: 'Text'},
        {name: 'imageDemo', title: 'Image'},
        {name: 'listBasic', title: 'List (Basic)'},
        {name: 'listDemo', title: 'List (Advanced)'},
        {name: 'sliderDemo', title: 'Slider'},
        {name: 'animation', title: 'Animation'},
        {name: 'modal', title: 'Modal'},
        {name: 'videoDemo', title: 'Video'},
        {name: 'calculator', title: 'Calculator'},
        {name: 'ui', title: 'UI Gallery'},
        {name: 'template', title: 'Example Template'}
      ]
    }},
    created: function() {
      var bundleUrl = this.$getConfig().bundleUrl;
      console.log('hit', bundleUrl);
      var nativeBase;
      var isAndroidAssets = bundleUrl.indexOf('your_current_IP') >= 0;
      var isiOSAssets = bundleUrl.indexOf('file:///') >= 0 && bundleUrl.indexOf('WeexDemo.app') > 0;
      if (isAndroidAssets) {
        nativeBase = 'file://assets/';
      }
      else if (isiOSAssets) {
        // file:///var/mobile/Containers/Bundle/Application/{id}/WeexDemo.app/
        // file:///Users/{user}/Library/Developer/CoreSimulator/Devices/{id}/data/Containers/Bundle/Application/{id}/WeexDemo.app/
        nativeBase = bundleUrl.substring(0, bundleUrl.lastIndexOf('/') + 1);
      }
      else {
        var host = 'localhost:12580';
        var matches = /\/\/([^\/]+?)\//.exec(this.$getConfig().bundleUrl);
        if (matches && matches.length >= 2) {
          host = matches[1];
        }
        nativeBase = '//' + host + '/examples/build/';
      }
      var h5Base = './index.html?page=./examples/build/';
      // in Native
      var base = nativeBase;
      if (typeof window === 'object') {
        // in Browser or WebView
        base = h5Base;
      }

      for (var i in this.cases) {
        var ca = this.cases[i];
        ca.url = base + ca.name + '.js';
      }
      // see log in Android Logcat
      console.log('hit', this.cases[0].url);
    }
  }


;module.exports.style = {}

;module.exports.template = {
  "type": "list",
  "children": [
    {
      "type": "cell",
      "append": "tree",
      "repeat": {
        "expression": function () {return this.cases}
      },
      "children": [
        {
          "type": "indexitem",
          "attr": {
            "title": function () {return this.title},
            "url": function () {return this.url}
          }
        }
      ]
    }
  ]
}

;})

// require module
bootstrap('@weex-component/index', {"transformerVersion":"0.3.0"})

it can't be parsed in android,but the content in assets is

define('@weex-component/ui-list-item', function (require, exports, module) {

;
  module.exports = {
    data: function () {return {
      bgColor: '#ffffff',
      click: function() {
      }
    }},
    methods: {
      touchstart: function() {
        // TODO adaptive opposite bgColor
//        this.bgColor = '#e6e6e6';
      },
      touchend: function() {
//        this.bgColor = '#ffffff';
      }
    }
  }


;module.exports.style = {
  "item": {
    "paddingTop": 25,
    "paddingBottom": 25,
    "paddingLeft": 35,
    "paddingRight": 35,
    "height": 160,
    "justifyContent": "center",
    "borderBottomWidth": 1,
    "borderColor": "#dddddd"
  }
}

;module.exports.template = {
  "type": "div",
  "classList": [
    "item"
  ],
  "events": {
    "click": "click",
    "touchstart": "touchstart",
    "touchend": "touchend"
  },
  "style": {
    "backgroundColor": function () {return this.bgColor}
  },
  "children": [
    {
      "type": "content"
    }
  ]
}

;})

// module

define('@weex-component/indexitem', function (require, exports, module) {

;
  module.exports = {
    data: function () {return {
      title: '',
      url: ''
    }},
    methods: {
      redirect: function() {
        this.$openURL(this.url);
      }
    }
  }


;module.exports.style = {
  "item-txt": {
    "fontSize": 48,
    "color": "#555555"
  }
}

;module.exports.template = {
  "type": "ui-list-item",
  "attr": {
    "click": function () {return this.redirect}
  },
  "children": [
    {
      "type": "text",
      "classList": [
        "item-txt"
      ],
      "attr": {
        "value": function () {return this.title}
      }
    }
  ]
}

;})

// module

define('@weex-component/index', function (require, exports, module) {

;
  module.exports = {
    data: function () {return {
      cases: [
        {name: 'hello', title: 'Hello World'},
//        {name: 'textDemo', title: 'Text'},
        {name: 'imageDemo', title: 'Image'},
        {name: 'listBasic', title: 'List (Basic)'},
        {name: 'listDemo', title: 'List (Advanced)'},
        {name: 'sliderDemo', title: 'Slider'},
        {name: 'animation', title: 'Animation'},
        {name: 'modal', title: 'Modal'},
        {name: 'videoDemo', title: 'Video'},
        {name: 'ui', title: 'UI Gallery'},
        {name: 'template', title: 'Example Template'}
      ]
    }},
    created: function() {
      var bundleUrl = this.$getConfig().bundleUrl;
      console.log('hit', bundleUrl);
      var nativeBase;
      if (bundleUrl.indexOf('your_current_IP') >= 0) { 
        // in Android assets
        nativeBase = 'file://assets/';
      }
      else {
        var host = 'localhost:12580';
        var matches = /\/\/([^\/]+?)\//.exec(this.$getConfig().bundleUrl);
        if (matches && matches.length >= 2) {
          host = matches[1];
        }
        nativeBase = '//' + host + '/examples/build/';
      }
      var h5Base = './index.html?page=./examples/build/';
      // in Native
      var base = nativeBase;
      if (typeof window === 'object') {
        // in Browser or WebView
        base = h5Base;
      }

      for (var i in this.cases) {
        var ca = this.cases[i];
        ca.url = base + ca.name + '.js';
      }
      // see log in Android Logcat
      console.log('hit', this.cases[0].url);
    }
  }


;module.exports.style = {}

;module.exports.template = {
  "type": "list",
  "children": [
    {
      "type": "cell",
      "append": "tree",
      "repeat": function () {return this.cases},
      "children": [
        {
          "type": "indexitem",
          "attr": {
            "title": function () {return this.title},
            "url": function () {return this.url}
          }
        }
      ]
    }
  ]
}

;})

// require module
bootstrap('@weex-component/index', {"transformerVersion":"0.1.8"})

it can be parsed.

from weex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.