0

I have the following dynamic var

{{ region }}

which could equal north, south, east or west.

I want to use it to pull in the variable from my data object

I tried

{{ #region.copy }}

Is this possible in vue

data: function() {
    return {
             north : {
                copy: "this is the north copy"
            },
            south : {
                copy: "this is the north copy"
            }

}

3
  • What do you mean "pull the appropriate copy"? Commented Feb 6, 2018 at 16:28
  • Copy of what? Could you explain a little-bit? Maybe provide more code of what you are doing. Commented Feb 6, 2018 at 16:28
  • sorry - updated, just a string from my data object. Commented Feb 6, 2018 at 16:31

1 Answer 1

3

You can put north, south, east and west in an object geo. In geo you can access your region by geo[region].copy. If region === south it will result in geo.south.copy

Edit: in computed variables you can also use this[region].copy instead of a geo wrap

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.