No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    separate the html template and vue functionality

    Framework
    5
    10
    815
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      eloy.silva last edited by

      Hello friends

      I have the following question, for the experts.
      Let’s imagine I have the file: Customer.vue

      you can have 2 separate files, Customer.vue, where is my html and another Customer2.vue file where is the functionality of vueJS

      it’s like before having an html and then we import the javascript where the logic is with vuejs

      best regards

      metalsadman J 2 Replies Last reply Reply Quote 0
      • metalsadman
        metalsadman @eloy.silva last edited by

        @eloy-silva read about mixins https://vuejs.org/v2/guide/mixins.html.

        E 1 Reply Last reply Reply Quote 0
        • E
          eloy.silva @metalsadman last edited by

          @metalsadman

          thanks

          1 Reply Last reply Reply Quote 0
          • W
            walfin last edited by

            @eloy-silva You might be interested in what I use:
            https://github.com/pksunkara/vue-builder-webpack-plugin

            I add it in quasar.conf.js like this:

            const VueBuilder=require('vue-builder-webpack-plugin')
            ...
            	extendWebpack(cfg){
            		cfg.plugins.push(new VueBuilder({
            			path:'src/components',
            			folder:true
            		}));
            ...
            

            The downside is that as a result, everything I create (including layouts) has to be under the components folder.

            1 Reply Last reply Reply Quote 0
            • J
              jraez @eloy.silva last edited by

              @eloy-silva you can give a try to pug. I’ll not suit 100% your requirement but it may helps.

              on your Customer2.vue your template will look like:

              <template lang="pug">
                include Customer.pug
              </termplate>
              

              Then you can take advantage of the pug possibilities (extends, include, create blocks, re-use template or fragment, etc.)

              E 1 Reply Last reply Reply Quote 0
              • E
                eloy.silva @jraez last edited by

                @jraez thanks

                1 Reply Last reply Reply Quote 0
                • s.molinari
                  s.molinari last edited by

                  To me, you are defeating the whole purpose of SFCs by separating the HTML and the JS code (and the CSS code). You say you’d like to have this but don’t mention the motivation. What is the motivation behind wanting to separate the HTML from the JS code?

                  Scott

                  E 1 Reply Last reply Reply Quote 0
                  • E
                    eloy.silva @s.molinari last edited by eloy.silva

                    @s-molinari said in separate the html template and vue functionality:

                    To me, you are defeating the whole purpose of SFCs by separating the HTML and the JS code (and the CSS code). You say you’d like to have this but don’t mention the motivation. What is the motivation behind wanting to separate the HTML from the JS code?

                    I worked some pages that way, using VueJS, where the work structure is:

                    in the HTML

                     
                        <script type="text/javascript" src=@Url.Content("~/js/PartnerSearch.js")></script>
                    

                    and the file PartnerSearch.js:

                    
                    var app = new Vue({
                        el: '#ui',
                        store: store,
                        data() {
                            return {
                                
                                tableData: [],
                                oSearch: {
                    
                                    CompanyID: "0",
                                    PartnerName: "",
                                    TaxIdentificationNumber:"",
                                    PageNumber: 1,
                                    PageSize: 0,
                                    SortExpression: " asc",
                                    TimeZoneHours: -5
                                },
                                oEntity: {
                                    CompanyID: 0,
                                    ProfileCode: ""
                                },
                                
                                oPagination: {
                                    Total: 0
                                },                    
                                QueryString: [],
                                Title: "",
                                SideMap: ""
                            };
                    
                        },
                        mixins: [mixin],
                    
                    .....
                    
                    
                    1 Reply Last reply Reply Quote 0
                    • s.molinari
                      s.molinari last edited by

                      So, like the UMD mode. i.e. not needing compilation?

                      If yes, you’ll learn this is a terrible way to develop Vue projects over time.

                      Scott

                      E 1 Reply Last reply Reply Quote 0
                      • E
                        eloy.silva @s.molinari last edited by

                        @s-molinari said in separate the html template and vue functionality:

                        So, like the UMD mode. i.e. not needing compilation?
                        If yes, you’ll learn this is a terrible way to develop Vue projects over time.

                        I see that, but I was curious 🙂

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post