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

How to create global vue variables in html and make it readable on .md files? #1252

Closed
lucassimines opened this issue Jun 27, 2020 · 2 comments · Fixed by #1271
Closed

How to create global vue variables in html and make it readable on .md files? #1252

lucassimines opened this issue Jun 27, 2020 · 2 comments · Fixed by #1271
Labels
bug confirmed as a bug question vuejs related to Vue.js

Comments

@lucassimines
Copy link

lucassimines commented Jun 27, 2020

How can I make my markdown files to get my Vue variables that I registered in my .html file?

I don't want to register the script inside .md files, is it possible to register in .html?

<script>
  new Vue({
    el: '#main',
    data: {
      appName: '<b>' + $docsify.name + '</b>',
      fullImg: '<b>1.920 x 1.080 px</b>. Formato: <b>.jpg</b> com <b>72 dpi</b>',
      mobileImg: '<b>1.080 x 1.920 px</b>. Formato: <b>.jpg</b> com <b>72 dpi</b>',
      squareImg: '<b>1.200 x 1.200 px</b>. Formato: <b>jpg</b> com <b>72 dpi</b>'
    }
  })
</script>
@jhildenbiddle
Copy link
Member

Addressed in #1271. Waiting on review and merge. Keep an eye on #752 as well.

@jhildenbiddle jhildenbiddle linked a pull request Oct 8, 2020 that will close this issue
@jhildenbiddle jhildenbiddle added vuejs related to Vue.js question bug confirmed as a bug labels Oct 8, 2020
@jhildenbiddle
Copy link
Member

@fmcdigital --

Fixed in #1271. Note that if you intent to use raw HTML as data, you will need to use the v-html directive:

# Text Data

## {{ appName }}

- {{ fullImg }}
- {{ mobileImg }}
- {{ squareImg }}

<script>
  new Vue({
    el: '#main',
    data: {
      appName: $docsify.name,
      fullImg: '1.920 x 1.080 px. Formato: .jpg com 72 dpi',
      mobileImg: '1.080 x 1.920 px. Formato: .jpg com 72 dpi',
      squareImg: '1.200 x 1.200 px. Formato: jpg com 72 dpi'
    }
  })
</script>
# Raw HTML DAta

## <span v-html="appName"></span>

- <span v-html="fullImg"></span>
- <span v-html="mobileImg"></span>
- <span v-html="squareImg"></span>

<script>
  new Vue({
    el: '#main',
    data: {
      appName: '<b>' + $docsify.name + '</b>',
      fullImg: '<b>1.920 x 1.080 px</b>. Formato: <b>.jpg</b> com <b>72 dpi</b>',
      mobileImg: '<b>1.080 x 1.920 px</b>. Formato: <b>.jpg</b> com <b>72 dpi</b>',
      squareImg: '<b>1.200 x 1.200 px</b>. Formato: <b>jpg</b> com <b>72 dpi</b>'
    }
  })
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed as a bug question vuejs related to Vue.js
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants