GithubHelp home page GithubHelp logo

Comments (13)

liximomo avatar liximomo commented on June 3, 2024

context 的 api 目前不是很明确,还需要等尤大给出更具体的 api 才可以实现。

from vue-function-api.

antfu avatar antfu commented on June 3, 2024

@liximomo 是否可以考虑按照现有的范例将现有api的this包装成context呢?

from vue-function-api.

liximomo avatar liximomo commented on June 3, 2024

from vue-function-api.

pangao66 avatar pangao66 commented on June 3, 2024

Context是不没有导出,
image
使用context也是无法正常使用的
console.log(context)
image
也都是这样的,都是undefined

from vue-function-api.

liximomo avatar liximomo commented on June 3, 2024

为什么需要导出Context?

from vue-function-api.

pangao66 avatar pangao66 commented on June 3, 2024

image
写ts的时候,Context作为interface

from vue-function-api.

liximomo avatar liximomo commented on June 3, 2024

setup(props, context)就足够了,可以自动推导出 context 的类型。

from vue-function-api.

pangao66 avatar pangao66 commented on June 3, 2024
setup(props, context) {
    const handleClick = () => {
      context.emit('send')
    }
    // watch
    return {
      handleClick
    }
  }

目前这样写是会无法使用的,
会报错
[Vue warn]: Error in v-on handler: "TypeError: context.emit is not a function"
版本2.0.4

from vue-function-api.

liximomo avatar liximomo commented on June 3, 2024

鼠标悬停 context 然我看看提示的是什么类型?

from vue-function-api.

pangao66 avatar pangao66 commented on June 3, 2024

image

类型是Context,也能输出,但是里面的字属性是undefined
console.log(context) 如下:
image

from vue-function-api.

liximomo avatar liximomo commented on June 3, 2024

这和类型没关系,这是因为值没有正确被代理到 context. 我修复一下

from vue-function-api.

liximomo avatar liximomo commented on June 3, 2024

@pangao66 升级到 2.0.5

from vue-function-api.

pangao66 avatar pangao66 commented on June 3, 2024

非常感谢

from vue-function-api.

Related Issues (9)

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.