mercredi 7 juin 2023

strict mode template error when using component

I defined a test component in emberjs, expect it output each value of testOpts, but got below error when rendering the page, how should I define the component ?

Uncaught (in promise) Error: Attempted to resolve a value in a strict mode template, but that value was not in scope: testOpts
    at encodeOp (opcode-compiler.js:2160:1)
    at pushOp (opcode-compiler.js:2067:1)
    at opcode-compiler.js:468:1
    at Compilers.compile (opcode-compiler.js:417:1)
    at expr (opcode-compiler.js:587:1)
    at CompilePositional (opcode-compiler.js:657:1)
    at SimpleArgs (opcode-compiler.js:633:1)
    at Call (opcode-compiler.js:719:1)
    at opcode-compiler.js:436:1
    at resolveHelper (opcode-compiler.js:229:1)

components/helper/test.hbs:

<div>

  testOpt: 
  
</div>

components/helper/test.js:

import Component from '@glimmer/component';

export default class TestComponent extends Component {
  get testOpts() {
    return ['a', 'b'];
  }
}

application.hbs

<Helper::Test />

if I don't use the output is fine, but I'm wondering how should I get to work.




Aucun commentaire:

Enregistrer un commentaire