【发布时间】:2020-07-17 22:07:51
【问题描述】:
使用这个 ACL library for Vue 我一直在尝试使用以下代码在 2 个文件中将 ACL 实现到 my Vue-based project:
main.js
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import Acl from "vue-browser-acl";
const user = { name: "Raj", role: "normal" };
Vue.use(Acl, user, acl => {
acl.rule("normal", "pages", user => user.role == "normal");
});
new Vue({
router,
store,
render: h => h(App)
}).$mount("#app");
pages/PageStats.vue
<template>
<div>
<h1 v-role:normal>This is the stats page authenticated</h1>
<h1>This is the stats page unauthenticated</h1>
</div>
</template>
<script>
export default {};
</script>
<style scoped></style>
但是,即使用户拥有role: "normal",我也看不到<h1 v-role:normal> 标签。我做错了什么?
【问题讨论】:
标签: vue.js vue-component vuex vue-router acl