App.vue 705 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. </div>
  5. </template>
  6. <script>
  7. import { mapState, createNamespacedHelpers } from 'vuex';
  8. const { mapActions } = createNamespacedHelpers('login');
  9. export default {
  10. created() {
  11. this.toLogin();
  12. },
  13. methods: {
  14. ...mapActions(['login']),
  15. async toLogin() {
  16. const obj = { username: 'wxyk', password: 'wxyk' };
  17. const res = await this.login(obj);
  18. if (res.code === 200) {
  19. const token = res.token;
  20. sessionStorage.setItem('token', token);
  21. }
  22. },
  23. },
  24. };
  25. </script>
  26. <style lang="less">
  27. p {
  28. padding: 0;
  29. margin: 0;
  30. }
  31. .textOver {
  32. overflow: hidden;
  33. text-overflow: ellipsis;
  34. white-space: nowrap;
  35. }
  36. </style>