3

I have login.vue file i want to add styling and I want include js and css files. I don't have any idea how to do in login.vue file.

Below is the html file

<!DOCTYPE html>
<html lang="en-US">
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1 user-scalable=no">
    <title>Teledirect Group &rsaquo; Log In</title>
    <link href="css/icons.css" rel="stylesheet">
    <link rel="icon" href="img/ico/tlogofvicon.png" type="image/png">
    <link rel="stylesheet" href="css/app.css">
    <link rel="stylesheet" id="dashicons-css" href="css/dashicons.min.css" type="text/css" media="all">
    <link rel='stylesheet' id='login-css'  href='css/login.min.css' type='text/css' media='all' /> 
    <style>
    .body_css{ 
        background: #fefefe none repeat scroll 0 0;
        color: #0a0a0a;
        font-family: "Helvetica Neue",Helvetica,Roboto,Arial,sans-serif;
        font-weight: normal;
        line-height: 1.5;
        margin: 0;
        padding: 0;
    }
    </style>
    </head> 
    <body class="body_css">
       <div class="main">
          <div id="particles-js" style="position: relative">
              <img src="img/logo-white.svg" alt="" class="logo" style="top: -51px;">
             <div style="text-align: center;
                          color: #fff;
                          position: absolute;
                          top: 44%;
                          margin-top: 50px;
                          width: 100%;
                          font-size: 16px;
                          font-weight: bold; ">
             Expense Claim System
             </div>
          </div>

             <div class="row login-cont">
              <div class="content form op2">
              <input type="hidden" name="reset_email" id="reset_email" value="<?php echo $remail;?>" />
              <input type="hidden" name="ccode" id="ccode" value="<?php echo $ccode;?>" /> 
              <div id="loginfrm">
                    <form name="login-form" id="login-form" method="post"> 
                          <span class="error-msg" style="display:none">Please enter your email | Please enter your password</span>
                        <p class="userlogin1">
                            <label for="user_login">
                            <input type="text" name="uname" id="uname" class="input" value="<?php if(isset($_COOKIE["member_login"])) { echo $_COOKIE["member_login"]; } ?>" size="20" placeholder="Username" /></label>
                        </p>
                        <p class="passwrd1">
                            <label for="user_pass" >
                            <input type="password" name="pwd" id="pwd" class="input" value="" size="20" placeholder="Password" /></label> 
                        </p>
                        <p class="forgetmenot1"> 
                        <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" value="forever"  /> Remember Me</label></p>
                        <p class="submit1">
                            <input type="hidden" id="action" name="action" value="login" >
                            <input type="submit" name="wp-submit" id="real_submit"  class="btn" value="Login" />
                                <input type="hidden" name="redirect_to" value="" />
                                <input type="hidden" name="testcookie" value="1" />
                                <span id="response_submit" style="display:none">
                                <a href="" class="btn btn-default pull-right">Checking... <img width="25" src="img/loading.gif" /></a>
                                </span>
                        </p>
                      <p>
                        <a href="#" title="Password Lost and Found"  class="frgt-password" style="cursor:pointer">Forgot password?</a>
                      </p>
                    </form>
                    </div> 
                    <div class="panel-footer gray-lighter-bg bt" id="response_note" style="display:none;">
                    </div>
                     <div id="forgetfrm" style="display:none"> 
                     <!-- forget password -->
                     <form name="lostpasswordform" id="lostpasswordform" method="post">
                        <span class="error-msg" style="display:none">Please enter your email or username</span>
                        <p>
                            <label for="user_login">
                                <input type="text" name="user_login" id="user_login"  class="input" value="" size="20" placeholder="Email or Username"/>
                            </label> 
                        </p> 
                        <input type="hidden" name="redirect_to" value="" />
                        <p class="submit" style="width:1000px;text-align:center;">  
                            <input type="submit" name="fp_submit" id="fp_submit"  value="Get New Password" />  
                        </p> 
                     </form>   
                     <p id="nav"><a href="" class="login-rvt">Log in</a></p>
                     <!-- End of forget password --> 
                </div>

                <div id="resetpwd" style="display:none"> 
                <form name="fresetpassform" id="fresetpassform" action="#" method="post" autocomplete="off"> 

                <span class="error-msg" style="display:none" >Please enter your new password</span>

                <p>
                    <label for="pass1" id="confm_pass1">
                    <input type="password" name="fpass1" id="fpass1" class="input" size="20" value="" autocomplete="off" placeholder="New Password" /></label>
                </p>
                <p>
                    <label for="pass2" id="confm_pass">
                    <input type="password" name="fpass2" id="fpass2"  class="input" size="20" value="" autocomplete="off" placeholder="Confirm new password" /></label>
                </p>
                <p class="submit" style="width:1000px;text-align:center;">
                <input type="submit" name="fwp-submit" id="fwp-submit" value="Reset Password" /></p> 
                </form> 
          </div> 
          <div class="clear"></div>
          <footer>
                <p class="account-copyright"><span>Copyright © <?php echo date("Y"); ?> </span><span>Teledirectgroup</span>. <span>All rights reserved.</span></p>
          </footer>
        </div>

        <!-- Important javascript libs(put in all pages) -->
        <script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
        <script>
            window.jQuery || document.write('<script src="{site_url}js/libs/jquery-2.1.1.min.js">\x3C/script>')
        </script>
        <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
        <script>
            window.jQuery || document.write('<script src="js/libs/jquery-ui-1.10.4.min.js">\x3C/script>')
        </script>
        <!-- Bootstrap plugins -->
        <script src="js/bootstrap/bootstrap.js"></script>
        <!-- Form plugins -->
        <script src="plugins/jquery.validate.js"></script>

        <!-- Top particles background -->
        <script src="js/pages/particles.js"></script>
        <script src="js/pages/app.js"></script>
        <script src="js/pages/login.js"></script>

        </body>
</html>



and below is login.vue file:

<template>

    <div class="card_data align-items-center">

        <b-card style="max-width: 25rem;" class="mb-2 shadow p-3 mb-5 bg-white rounded">
            <b-alert variant="danger" dismissible v-model="showDismissibleAlert">
                {{ alertMessage }}
            </b-alert>
            <h4 style="text-align: center">Login Panel</h4>
            <hr>
            <b-form @submit="onSubmit">
                <b-form-group id="username" label="Username:" label-for="username" class="font-weight-bold">
                    <b-form-input id="username" type="text" v-model="form.username" required placeholder="Enter email or merchant id" />
                </b-form-group>

                <b-form-group id="password" label="Password:" label-for="password" class="font-weight-bold">
                    <b-form-input id="password" type="password" v-model="form.password" required placeholder="Enter password" />
                </b-form-group>
                <b-row class="mt-4">
                    <b-col class="text-center">
                        <b-button type="submit" variant="primary" size="lg" class="text-center">Submit</b-button>
                    </b-col>
                </b-row>
            </b-form>
        </b-card>

    </div>

</template>

<style>
    .card_data {

        background: #fefefe none repeat scroll 0 0;
        color: #0a0a0a;
        font-family: "Helvetica Neue",Helvetica,Roboto,Arial,sans-serif;
        font-weight: normal;
        line-height: 1.5;
        margin: 0;
        padding: 0;

    }


</style>

<script>
    export default {
        name: 'LoginPage',
        data() {
            return {
                form: {
                    username: '',
                    password: ''
                },
                show: true,
                alertMessage: 'Wrong Credentials',
                showDismissibleAlert: false,
                baseUrl: '',
            }
        },
        methods: {
            onSubmit(evt) {
                let loader = this.$loading.show({
                    container: this.fullPage ? null : this.$refs.file,
                });

                this.showDismissibleAlert = false
                evt.preventDefault();

                var bodyFormData = new FormData();
                bodyFormData.set('email', this.form.username);
                bodyFormData.set('password', this.form.password);
                this.axios({
                        method: 'post',
                        url: this.baseUrl + 'portal/login',
                        data: bodyFormData
                    })
                    .then((response) => {
                        loader.hide();
                        if (response.data.success == true) {
                            this.showDismissibleAlert = false;
                            this.$store.commit('setLogin', true );
                            this.$toast.open({
                                message: 'Login was success',
                                type: 'success'
                            });
                            // console.log(this.$store.getters.getLogin);
                            this.$router.push('/');

                        } else {
                                this.$toast.open({
                                message: 'Invalid Credentials',
                                type: 'error'
                            });
                        }
                    })
                    .catch(function(response) {
                        loader.hide();
                    });
            },

            onReset(evt) {
                evt.preventDefault()
                this.form.username = '';
                this.form.password = '';
                this.show = false;
                this.$nextTick(() => {
                    this.show = true;
                })
            }
        },
        mounted() {
            this.baseUrl = this.$store.getters.getUrl;
        },
    }

</script>

I have a login.vue file I want to add styling and I want to include js and css files. I don't have any idea how to do in the login.vue file.

1
  • I mean, you can just use it as is... Vue syntax is just HTML. As to where to simplify (i.e make use of Vue's syntax fully)/split into multiple files, [Code Review SE](codereview.stackexchange.com) might be a better place to ask. Commented Aug 13, 2019 at 9:07

1 Answer 1

6

You would import it in your style tag like this:

 <style>
    @import './css/app.css';
 </style>

As for the js file just import it at the top of the export default like this:

import myJsFile from "./js/myJsFile"

export default {
...
}
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.