1

I tried binding a value to an input using a variable that has been declared in the data object, but I also need to add a prefix and a suffix

<input id="topnavback", v-bind:value="rgb({{themestopnavback}})", class="jscolor"/>

The value themetopnavback is the value defined in data and I want to put the rgb with bracktes around it.

But this always causes the whole page not to render the DOM which only occurs if you try to access a Vue variable which isn't existing in the data object. Is this just wrong or isn't it possible to bind a value with additional strings?

Thanks in advance

6
  • Why not just rgb(themestopnavback)? Commented Mar 27, 2017 at 17:43
  • That also won't let the DOM render...are you sure that vue should recognize that expression? Commented Mar 27, 2017 at 17:51
  • Is rgb defined on your Vue? Is themestopnavback? Show your Vue. Commented Mar 27, 2017 at 17:53
  • No, themestopnavback is defined there, not rgb. The value of themestopnavback only contains the numbers that needs to be in brackets with the rgb in front of it. Also, my Vue is pretty big, I don't think it would make sense to post all of it here, but I defined it correctly, that's for sure. Commented Mar 27, 2017 at 17:59
  • Where is the rgb function defined? Is it just a string? Commented Mar 27, 2017 at 18:00

1 Answer 1

3
v-bind:value="'rgb(' + themestopnavback + ')'"
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.