Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add class #37

Open
lng0415 opened this issue Jan 21, 2021 · 1 comment
Open

add class #37

lng0415 opened this issue Jan 21, 2021 · 1 comment

Comments

@lng0415
Copy link

lng0415 commented Jan 21, 2021

Hi.
i cant understand onClassName option.
how to use that?
ex) if select city, add class to city

<v-jsoneditor v-model="cities" :options="vjsonOpt"></v-jsoneditor>

<select cities.....  v-model='city'>
  <option ...>
...
<script>
export default {
  data() {
    return {
      city: null,
      vjsonOpt: {
        mode: 'view',
        onClassName: function(node) {
           if (this.city) {
             if (node.field == 'london') {
               // set textRed
             } else if (node.field == 'newyork') {
               // set textBlue
             } else {
             }
          }
        }
      },
      cities: {
        london: 'uk',
        newyork: 'usa'
        ottawa: 'canada',
        paris: 'france'
      }
    }
  },
  methods: {
  }
}
</script>
<style>
.textRed {color: #e42e21;}
.textBlue {color: #1404ee;}
</style>
@yansenlei
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants