要解决Angular的quill-editor无法将文本左对齐的问题,您可以尝试以下解决方法:
在您的组件的CSS文件中添加以下样式:
/deep/ .ql-editor {
text-align: left !important;
}
首先,在组件中导入Renderer2:
import { Component, OnInit, Renderer2, ViewChild } from '@angular/core';
@Component({
selector: 'app-your-component',
templateUrl: './your-component.component.html',
styleUrls: ['./your-component.component.css']
})
export class YourComponent implements OnInit {
@ViewChild('quillEditor') quillEditor: any;
constructor(private renderer: Renderer2) { }
ngOnInit() {
// 在ngAfterViewInit生命周期钩子中设置对齐方式
this.renderer.setStyle(this.quillEditor.editorElem, 'text-align', 'left');
}
}
然后,在HTML模板中使用ViewChild来引用quill-editor组件:
请注意,上述解决方法中的代码可能需要根据您的具体情况进行修改。