Article From:

This is what it says in the document:

How to distribute global events in weex-html5 components or modules? Only the event is assigned on the document element:

var evt = new Event('some-type') = { foo: 'bar' }

I do not work this way

  watch: {
    'speces' (val) {
        var evt = new Event('goods-update') = { name: 'speces', data: JSON.parse(JSON.stringify(val)) }

Answer 0:…
You can look at this part of the document
I wrote a simple example

var globalEvent = weex.requireModule('globalEvent');
globalEvent.addEventListener("goods-update", function(e) {
  console.log("get event:"+JSON.stringify(e))
export default {
  data: {
    target: 'World'
  methods: {
    update: function(e) {
      // The trigger should not be placed here. It should be web, IOS and andorid to write a module to trigger each other./ / the code should only run on the web side; ios& Android running should be wrong.Var Val = {"X": "2"})Var EVT = new Event ('goods-update') = {name:'speces'Data: JSON.parse (JSON.stringify (VAL))}Document.dispatchEvent (EVT)},}}< /script>

Answer 1:

A module is extended at native.
We’ve extended a notification module at native, which is acceptable on any page, weex, vue, and sends notifications for global event communication.

Leave a Reply

Your email address will not be published. Required fields are marked *