Turning jQuery Code into Vue.js


 
Thread Tools Search this Thread
Top Forums Web Development Turning jQuery Code into Vue.js
# 1  
Old 11-11-2018
We got a suggestion from over a the vue forums:

Bind Vue.js variable to external Javascript variable for reactivity - Get Help - Vue Forum

Alex:

Quote:
Try this.
Code:
var app = new Vue({
    el: '#app',
    data: {
        message: 'Hello Vue!'
    }
})

var myVar = {
    get a() {
        return app.message
    },
    set a(b) {
	app.message = b
    }
}

Quote:
BTW using v-html is not a very good idea.

Instead, you can bind src to a variable and also use conditional rendering:
Code:
<img :src="vbtheURL" v-if="vbuserId">

Quote:
You can do the same for styles:
Code:
<span :style="avatarStyle" v-else>

Code:
computed: {
    avatarStyle() {
        return {
             'font-size': '3em',
             cursor: 'pointer',
             /* etc... */
        }
    }
}

Thank you Alex from the Vue forums .... we will try these suggestions and post back our results.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Web Development

Vue.js component: Beautiful code highlighter

Sooner than later I will render forum discussions in Vue.js to complement the standard way of showing forum threads. Today, I ran across this component, vue-code-highlight Beautiful code syntax highlighting as Vue.js component. https://www.unix.com/members/1-albums225-picture1199.jpg ... (1 Reply)
Discussion started by: Neo
1 Replies

2. Web Development

Vue JS 2 Tutorial by The Net Ninja: A Recommended Vue.js Video Tutorial Series

A number of people have asked me how to get started with Vue.js and my reply before today was to Google "Vue.js". That has changed and my recommendation to anyone who wants to learn the fastest growing, easiest to learn and use Vue.js web dev framework is to watch this video tutorial series: ... (0 Replies)
Discussion started by: Neo
0 Replies

3. Web Development

Simple Vue.js Component to Redirect to External Web Page Using Vue Router

Vue Router has some quirks and on of the quirks is that it is not reliable when adding external links using the vue-router library. After struggling with many solutions, I have found that creating a simple Vue.js component like this one seems to work the best (so far): Component Example: ... (0 Replies)
Discussion started by: Neo
0 Replies

4. What is on Your Mind?

JQuery to Add Code Tags to Selected Text

Hey. Someone find or write some jQuery code where we can select text with our mouse and then click or double click the highlighted / selected text and then it will wrap code tags around the highlighted text (in our editors). :) (0 Replies)
Discussion started by: Neo
0 Replies

5. What is on Your Mind?

JQuery and CSS Flex Code for Responsive Forum Home Page

So far, I have completed making the home page more responsive (except for the forum stats at the top and the WOL box at the bottom, they still use scroll bars). xevV3_iZ8-s For full screen use the link below and set your YT resolution to 1080p60 HD https://youtu.be/xevV3_iZ8-s Here is... (1 Reply)
Discussion started by: Neo
1 Replies

6. What is on Your Mind?

JQuery and CSS Flex Code for Responsive WOL Page

I have just wrote this jQuery to the WOL page, so the table of users on line will not need scrollbars and will instead transform into a responsive table: <script> jQuery(document).ready(function (){ jQuery("#neo-who-flex-tcat"). css({"display":"flex","flex-flow":"row wrap", ... (0 Replies)
Discussion started by: Neo
0 Replies
Login or Register to Ask a Question