Vue 学习--Vue Todo List 项目的准备

1 安装node.js

官网下载 (nodejs.cn

(并在根目录 新建两个文件:cache   global)

npm已经在Node.js安装的时候顺带装好了。

配置环境变量:

2 设置淘宝镜像

下载cnpm 

注意:

3 安装 vue-cli 

4 创建第一个项目

4.1 使用vue create创建,打开终端输入vue create +(项目名称)即可创建

(另外:)

4.2运行项目:npm run serve  

(我在运行时出现报错,

将项目名改为: cd  name  便成功运行了 

参考以下文献  http://t.csdnimg.cn/8j71h

4.3打开Localhost,就可以看到VUE的Hello World界面

4.3 npm run build

5 项目结构

5.1组件的组成部分

5.2 Element 快速入门

引入element

常见组件:
table表格
pagination分页
Dialog对话框
Form表单

  • 7
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
可以通过自定义 Quill 的 toolbar 实现图片的拉伸、放大和缩小。 首先,你需要在 `vue-quill-editor` 的配置中添加一个自定义的 toolbar。例如: ``` <quill-editor v-model="content" :options="editorOption" > <div v-if="editorOption.toolbar"> <span class="ql-formats"> <select class="ql-size"> <option value="small"></option> <option selected></option> <option value="large"></option> <option value="huge"></option> </select> </span> <span class="ql-formats"> <button class="ql-stretch"></button> <button class="ql-zoom-in"></button> <button class="ql-zoom-out"></button> </span> <span class="ql-formats"> <button class="ql-image"></button> </span> </div> </quill-editor> ``` 然后,在 `mounted()` 钩子函数中获取 Quill 实例,并添加自定义的 toolbar 按钮的逻辑。例如: ``` mounted() { this.$nextTick(() => { const quill = this.$refs.myQuillEditor.quill const stretchButton = quill.getModule('toolbar').container.querySelector('.ql-stretch') const zoomInButton = quill.getModule('toolbar').container.querySelector('.ql-zoom-in') const zoomOutButton = quill.getModule('toolbar').container.querySelector('.ql-zoom-out') stretchButton.addEventListener('click', function() { // todo: 进行图片拉伸的逻辑 }) zoomInButton.addEventListener('click', function() { // todo: 进行图片放大的逻辑 }) zoomOutButton.addEventListener('click', function() { // todo: 进行图片缩小的逻辑 }) }) } ``` 其中,`quill.getModule('toolbar').container` 获取到的是 Quill 的 toolbar 容器,可以通过 `querySelector()` 方法获取到自定义按钮的 DOM 元素并添加事件监听器。 接下来,你需要实现图片拉伸、放大和缩小的逻辑。可以通过 Quill 的 Delta API 获取到当前选中的图片,并对其属性进行修改。例如: ``` stretchButton.addEventListener('click', function() { const range = quill.getSelection() if (!range) return const [image] = quill.getSemanticHTML(range.index, range.length).match(/<img.*?>/g) if (image) { quill.updateContents(new Delta().retain(range.index).delete(range.length).insert({ image: { ...Quill.Attributor.AttributeList.fromHTML(image), width: '200px', height: 'auto' } })) } }) ``` 上面的代码中,首先获取到当前选中的图片(即 `<img>` 标签),然后通过 Quill 的 `updateContents()` 方法修改图片的属性,例如将其宽度设置为 200px,高度设置为自适应。 类似地,你可以实现图片的放大和缩小。例如: ``` zoomInButton.addEventListener('click', function() { const range = quill.getSelection() if (!range) return const [image] = quill.getSemanticHTML(range.index, range.length).match(/<img.*?>/g) if (image) { const attr = Quill.Attributor.AttributeList.fromHTML(image) const width = parseInt(attr.width.replace('px', '')) const height = parseInt(attr.height.replace('px', '')) quill.updateContents(new Delta().retain(range.index).delete(range.length).insert({ image: { ...attr, width: `${width + 10}px`, height: `${height + 10}px` } })) } }) zoomOutButton.addEventListener('click', function() { const range = quill.getSelection() if (!range) return const [image] = quill.getSemanticHTML(range.index, range.length).match(/<img.*?>/g) if (image) { const attr = Quill.Attributor.AttributeList.fromHTML(image) const width = parseInt(attr.width.replace('px', '')) const height = parseInt(attr.height.replace('px', '')) if (width > 10 && height > 10) { quill.updateContents(new Delta().retain(range.index).delete(range.length).insert({ image: { ...attr, width: `${width - 10}px`, height: `${height - 10}px` } })) } } }) ``` 上面的代码中,首先获取到当前选中的图片的宽度和高度,然后将其分别增加或减少 10px。需要注意的是,当图片的宽度或高度小于等于 10px 时,不能再继续缩小了。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值