我需要将字符串转换为某种形式的哈希.这在JavaScript中可行吗?
我没有使用服务器端语言,所以我不能这样做.
我正在尝试使用带有vue-uuid的随机字符串 (UUID v4)来表示当前项目和将来添加到列表中的项目(这是一个待办事项列表类型的应用程序),但我不确定要纠正什么语法是。
我安装了它并将其添加到我在 main.js 中的项目中:
import UUID from 'vue-uuid';
Vue.use(UUID);
Run Code Online (Sandbox Code Playgroud)
但是,我不知道如何在我的 Vue 组件中使用它。这是我尝试过的:
模板:
<transition-group
name="list"
enter-active-class="animated bounceInUp"
leave-active-class="animated bounceOutDown"
>
<li v-for="item in skills" :key="uuid">{{ item.skill }}</li>
</transition-group>
Run Code Online (Sandbox Code Playgroud)
脚本:
import { uuid } from 'vue-uuid';
export default {
name: 'Skills',
data() {
return {
uuid: uuid.v4(),
skill: '',
skills: [{ skill: 'Vue.js' }, { skill: 'React' }]
};
},
};
Run Code Online (Sandbox Code Playgroud)
因为:key="uuid",我收到一条错误消息Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' …