Skip to content
This repository has been archived by the owner. It is now read-only.

在自定义组件上无法调用 inline handler #1624

Open
Neeeo opened this issue Nov 11, 2016 · 9 comments
Open

在自定义组件上无法调用 inline handler #1624

Neeeo opened this issue Nov 11, 2016 · 9 comments

Comments

@Neeeo
Copy link

@Neeeo Neeeo commented Nov 11, 2016

下面这样形式的调用无法触发,ar-button是在另一个we文件里定义的。

<ar-button style="margin-right: 20;" value="下载" onclick="tap($index, $event)"></ar-button>

只能触发这样的形式:

<ar-button style="margin-right: 20;" value="下载" onclick="tap"></ar-button>
@MrRaindrop

This comment has been minimized.

Copy link
Member

@MrRaindrop MrRaindrop commented Nov 19, 2016

Hi, 你看下在你的环境里以下代码是否正常运行:

<template>
  <div>
    <text onclick="test('MSG!!!', $event)">TEST</text>
  </div>
</template>

<script>
  var modal = require('@weex-module/modal')
  module.exports = {
    methods: {
      test: function (msg, evt) {
        modal.toast({
          message: 'msg:' + msg     // msg:MSG!!!
        })
      }
    }
  }
</script>

这段代码在最新 dev 分支下应该是正常运行的,而且这个写法在比较早期就已经支持了。如果不行,可以把你的运行环境,包括运行设备,操作系统,weex 版本号等信息提供一下。

@Neeeo

This comment has been minimized.

Copy link
Author

@Neeeo Neeeo commented Nov 19, 2016

在系统自带组件上没问题,我说的是在自定义子组件上(we文件定义的,不是native提供的)。

@MrRaindrop

This comment has been minimized.

Copy link
Member

@MrRaindrop MrRaindrop commented Nov 21, 2016

确实有问题,这里补充一下出错用例:

<element name="foo">
  <template>
    <div><text>TEST</text></div>
  </template>
</element>

<template>
  <div>
    <foo onclick="test('MSG!!!', $event)"></foo>
  </div>
</template>

<script>
  var modal = require('@weex-module/modal')
  module.exports = {
    methods: {
      test: function (msg, evt) {
        modal.toast({
          message: 'msg:' + msg     // msg:MSG!!!
        })
      }
    }
  }
</script>
@Jinjiang

This comment has been minimized.

Copy link
Contributor

@Jinjiang Jinjiang commented Nov 28, 2016

#1502 问题重复了,我们继续保留这边跟进

@Hanks10100

This comment has been minimized.

Copy link
Member

@Hanks10100 Hanks10100 commented Jan 4, 2017

我本地测试了一下,下边这个例子是可以正常工作的:

<template>
  <div>
  <div repeat="{{v in viewData}}" onclick="clicked($index)">
    <text>{{v}}</text>
  </div>
  </div>
</template>

<script>
  module.exports = {
    data: {
      viewData: ['a', 'b', 'c']
    },
    methods: {
      clicked: function(position) {
        console.log("被点到了:" + position)
      },
    }
  }
</script>

线上网站 http://dotwe.org/ 中的 js framework 和 weex-html5 版本都较低,最近会升级。

@Hanks10100 Hanks10100 closed this Jan 4, 2017
@Neeeo

This comment has been minimized.

Copy link
Author

@Neeeo Neeeo commented Jan 5, 2017

请看清问题再说,问题说的是在一个自定义组件上有问题,下面也有人回复测试用例。你发的这完全不是一件事

@Hanks10100

This comment has been minimized.

Copy link
Member

@Hanks10100 Hanks10100 commented Jan 5, 2017

Sorry, 是我理解错了,之前遇到过同类问题是由于线上版本太低导致的。@fkysly 看一下具体怎么回事。

@Hanks10100 Hanks10100 reopened this Jan 5, 2017
@Jinjiang Jinjiang added legacy framework and removed js runtime labels Mar 1, 2017
@luoyang125024608

This comment has been minimized.

Copy link

@luoyang125024608 luoyang125024608 commented Mar 27, 2017

<wxbutton class="button" title="jump" @click="jump" ></wxbutton> <text class="button" @click="jump">Jump</text>

自定义components上的@click没有响应哦 在ios代码里没有addTarget监听,@click还是不起作用。其他组件没问题。用的是vue
image
image
自定义组件没有进入该方法
和vue还不支持globalEvent有关吗?

@YorkShen

This comment has been minimized.

Copy link

@YorkShen YorkShen commented Feb 18, 2019

This PR/issue doesn't receive response since Weex migrated to Apache two years ago and this repository is no longer active yet.

Feel free to ask question in new repository and thanks for your contribution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
7 participants
You can’t perform that action at this time.