Giter Site home page Giter Site logo

Comments (2)

Rich-Harris avatar Rich-Harris commented on September 27, 2024 5

This is all excellent feedback, thanks. Will work more on the docs when I can, but briefly:

  • Properties of data and computed can be used in mustache tags and as arguments to event handlers. The same goes for helpers, which is really just an extension of data (but I've found a lot of people get weirded out by having functions in an object called 'data')
  • methods are added to the component's prototype – i.e. if you have a foo method than you will be able to do component.foo(...) in your app. You can also call methods (built-in or custom) inside event handlers in your template – in an on:somevent='foo(bar)' directive, foo(...) must be a method, bar must be a property of data or computed
  • Inside a method, this is always the component
  • In the event handler itself, this is the node – so <input on:input='log(this.value)'> means 'call the log method with the value of the the <input>'. Demo: https://svelte.technology/repl/?gist=b709873e61bbf7fed5d84ab0ca14ea86
  • Name collisions will cause a compile time error – the compiler is strict, it won't let you make that sort of mistake

Hope this sheds some light!

from svelte.

Conduitry avatar Conduitry commented on September 27, 2024

Scope is a bit simpler in v3, and I think adequately covered in the documentation. Closing.

from svelte.

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.